/translit

Primary LanguageCGNU Lesser General Public License v3.0LGPL-3.0

translit – Transliterate between Unicode and smaller coded character sets

Example usage

>>> import translit >>> text = "La question, c’estu202f: «u202fOù est le cœuru202f?u202f»"

Downgrade text to Latin-1:

>>> translit.downgrade(text, "latin-1") "La question, c'estxa0: «xa0Où est le coeurxa0?xa0»"

Downgrade text to ASCII:

>>> translit.downgrade(text, "ascii") 'La question, c'est : "Ou est le coeur ?"'

Downgrade and encode to Latin-1:

>>> buf = text.encode("latin-1/translit") >>> buf b"La question, c'estxa0: xabxa0Oxf9 est le coeurxa0?xa0xbb"

Decoding, the normal way:

>>> buf.decode("latin-1") "La question, c'estxa0: «xa0Où est le coeurxa0?xa0»"

Decoding, the upgraded way:

>>> buf.decode("latin-1/translit/fr") 'La question, c’estu202f: «u202fOù est le cœuru202f?u202f»'

Installation

To install the package for Python 3, use:

$ ./setup.py install

To install the package for Python 2, use:

$ python2 setup.py install

On Windows, you may use one of the MSI binary packages provided on the download page.

Requirements