Imitates get_normal_name in tokenizer.c.
(orig_enc)
| 286 | |
| 287 | |
| 288 | def _get_normal_name(orig_enc): |
| 289 | """Imitates get_normal_name in tokenizer.c.""" |
| 290 | # Only care about the first 12 characters. |
| 291 | enc = orig_enc[:12].lower().replace("_", "-") |
| 292 | if enc == "utf-8" or enc.startswith("utf-8-"): |
| 293 | return "utf-8" |
| 294 | if enc in ("latin-1", "iso-8859-1", "iso-latin-1") or \ |
| 295 | enc.startswith(("latin-1-", "iso-8859-1-", "iso-latin-1-")): |
| 296 | return "iso-8859-1" |
| 297 | return orig_enc |
| 298 | |
| 299 | def detect_encoding(readline): |
| 300 | """ |
no test coverage detected