MCPcopy Create free account
hub / github.com/Sigil-Ebook/Sigil / _unidecode

Function _unidecode

src/Resource_Files/python3lib/unidecode/__init__.py:117–138  ·  view source on GitHub ↗
(string: str, errors: str, replace_str:str)

Source from the content-addressed store, hash-verified

115 return None
116
117def _unidecode(string: str, errors: str, replace_str:str) -> str:
118 retval = []
119
120 for index, char in enumerate(string):
121 repl = _get_repl_str(char)
122
123 if repl is None:
124 if errors == 'ignore':
125 repl = ''
126 elif errors == 'strict':
127 raise UnidecodeError('no replacement found for character %r '
128 'in position %d' % (char, index), index)
129 elif errors == 'replace':
130 repl = replace_str
131 elif errors == 'preserve':
132 repl = char
133 else:
134 raise UnidecodeError('invalid value for errors parameter %r' % (errors,))
135
136 retval.append(repl)
137
138 return ''.join(retval)

Callers 2

unidecode_expect_asciiFunction · 0.85

Calls 3

_get_repl_strFunction · 0.85
UnidecodeErrorClass · 0.85
appendMethod · 0.80

Tested by

no test coverage detected