Skip to content

Commit 62dbc4c

Browse files
committed
Add a workaround for python codec normalization
1 parent 52ca4f0 commit 62dbc4c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

iconvcodec.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,14 @@ def _iconv_decode_impl(decoder, msg, errors, bufsize=None):
8080

8181

8282
def codec_factory(encoding):
83-
encoder = iconv.open(encoding, "utf-8")
84-
decoder = iconv.open("utf-8", encoding)
83+
# Workaround for https://github.com/bodograumann/python-iconv/issues/4
84+
_encoding = encoding \
85+
.replace("_translit", "//TRANSLIT") \
86+
.replace("_ignore", "//IGNORE") \
87+
.replace("_non_identical_discard", "//NON_IDENTICAL_DISCARD")
88+
89+
encoder = iconv.open(_encoding, "utf-8")
90+
decoder = iconv.open("utf-8", _encoding)
8591

8692
def encode(inp, errors="strict"):
8793
msg = inp.encode()

0 commit comments

Comments
 (0)