(string: str, errors: str, replace_str:str)
| 115 | return None |
| 116 | |
| 117 | def _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) |
no test coverage detected