Imitates get_normal_name in Parser/tokenizer/helpers.c.
(orig_enc)
| 345 | |
| 346 | |
| 347 | def _get_normal_name(orig_enc): |
| 348 | """Imitates get_normal_name in Parser/tokenizer/helpers.c.""" |
| 349 | # Only care about the first 12 characters. |
| 350 | enc = orig_enc[:12].lower().replace("_", "-") |
| 351 | if enc == "utf-8" or enc.startswith("utf-8-"): |
| 352 | return "utf-8" |
| 353 | if enc in ("latin-1", "iso-8859-1", "iso-latin-1") or \ |
| 354 | enc.startswith(("latin-1-", "iso-8859-1-", "iso-latin-1-")): |
| 355 | return "iso-8859-1" |
| 356 | return orig_enc |
| 357 | |
| 358 | def detect_encoding(readline): |
| 359 | """ |
no test coverage detected
searching dependent graphs…