diff options
| author | Tomaz Solc <tomaz.solc@tablix.org> | 2015-11-17 11:47:25 +0100 |
|---|---|---|
| committer | Tomaz Solc <tomaz.solc@tablix.org> | 2015-11-17 11:47:25 +0100 |
| commit | dcf0f972de878319fd103ba28d3e6795bc34da00 (patch) | |
| tree | e687c7c66b75826e4780a944d7fcf050925d71dd /unidecode | |
| parent | be04113429619571dc3f639bdf6db4f05a1e6fd3 (diff) | |
| download | unidecode-dcf0f972de878319fd103ba28d3e6795bc34da00.tar.gz | |
Rename unidecode_fast to unidecode_expect_ascii
Also, add unidecode_expect_nonascii. "unidecode" is now an alias for
"unidecode_expect_ascii"
Diffstat (limited to 'unidecode')
| -rw-r--r-- | unidecode/__init__.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/unidecode/__init__.py b/unidecode/__init__.py index 94dd970..13fc950 100644 --- a/unidecode/__init__.py +++ b/unidecode/__init__.py @@ -28,7 +28,7 @@ def _warn_if_not_unicode(string): RuntimeWarning, 2) -def unidecode_fast(string): +def unidecode_expect_ascii(string): """ Try to transliterate using ASCII codec. If it fails, fall back to transliteration using the character tables. @@ -41,20 +41,24 @@ def unidecode_fast(string): try: bytestring = string.encode('ASCII') except UnicodeEncodeError: - return unidecode(string) + return _unidecode(string) if version_info[0] >= 3: return string else: return bytestring +def unidecode_expect_nonascii(string): + _warn_if_not_unicode(string) + return _unidecode(string) + +unidecode = unidecode_expect_ascii -def unidecode(string): +def _unidecode(string): """Transliterate an Unicode object into an ASCII string >>> unidecode(u"\u5317\u4EB0") "Bei Jing " """ - _warn_if_not_unicode(string) retval = [] |
