{"id":13468250,"url":"https://github.com/avian2/unidecode","last_synced_at":"2026-02-22T14:34:44.951Z","repository":{"id":24820772,"uuid":"28235238","full_name":"avian2/unidecode","owner":"avian2","description":"ASCII transliterations of Unicode text - GitHub mirror","archived":false,"fork":false,"pushed_at":"2024-04-30T14:55:47.000Z","size":687,"stargazers_count":524,"open_issues_count":19,"forks_count":62,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-29T22:55:59.457Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/Unidecode","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avian2.png","metadata":{"files":{"readme":"README.rst","changelog":"ChangeLog","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-12-19T15:44:27.000Z","updated_at":"2024-10-21T00:59:57.000Z","dependencies_parsed_at":"2023-10-20T17:58:55.711Z","dependency_job_id":"9f4f81a0-1d6b-405b-a3a0-35a571d3ba16","html_url":"https://github.com/avian2/unidecode","commit_stats":{"total_commits":267,"total_committers":26,"mean_commits":10.26923076923077,"dds":"0.19475655430711614","last_synced_commit":"539e82a4fc4646b738fbbbf00f98cec5db8a534b"},"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avian2%2Funidecode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avian2%2Funidecode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avian2%2Funidecode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avian2%2Funidecode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avian2","download_url":"https://codeload.github.com/avian2/unidecode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245597201,"owners_count":20641859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T15:01:07.603Z","updated_at":"2026-02-22T14:34:44.896Z","avatar_url":"https://github.com/avian2.png","language":"Python","readme":"Unidecode, lossy ASCII transliterations of Unicode text\n=======================================================\n\nIt often happens that you have text data in Unicode, but you need to\nrepresent it in ASCII. For example when integrating with legacy code that\ndoesn't support Unicode, or for ease of entry of non-Roman names on a US\nkeyboard, or when constructing ASCII machine identifiers from human-readable\nUnicode strings that should still be somewhat intelligible. A popular example\nof this is when making an URL slug from an article title.\n\n**Unidecode is not a replacement for fully supporting Unicode for strings in\nyour program. There are a number of caveats that come with its use,\nespecially when its output is directly visible to users. Please read the rest\nof this README before using Unidecode in your project.**\n\nIn most of examples listed above you could represent Unicode characters as\n``???`` or ``\\\\15BA\\\\15A0\\\\1610``, to mention two extreme cases. But that's\nnearly useless to someone who actually wants to read what the text says.\n\nWhat Unidecode provides is a middle road: the function ``unidecode()`` takes\nUnicode data and tries to represent it in ASCII characters (i.e., the\nuniversally displayable characters between 0x00 and 0x7F), where the\ncompromises taken when mapping between two character sets are chosen to be\nnear what a human with a US keyboard would choose.\n\nThe quality of resulting ASCII representation varies. For languages of\nwestern origin it should be between perfect and good. On the other hand\ntransliteration (i.e., conveying, in Roman letters, the pronunciation\nexpressed by the text in some other writing system) of languages like\nChinese, Japanese or Korean is a very complex issue and this library does\nnot even attempt to address it. It draws the line at context-free\ncharacter-by-character mapping. So a good rule of thumb is that the further\nthe script you are transliterating is from Latin alphabet, the worse the\ntransliteration will be.\n\nGenerally Unidecode produces better results than simply stripping accents from\ncharacters (which can be done in Python with built-in functions). It is based\non hand-tuned character mappings that for example also contain ASCII\napproximations for symbols and non-Latin alphabets.\n\n**Note that some people might find certain transliterations offending.** Most\ncommon examples include characters that are used in multiple languages. A user\nexpects a character to be transliterated in their language but Unidecode uses a\ntransliteration for a different language. It's best to not use Unidecode for\nstrings that are directly visible to users of your application. See also the\n*Frequently Asked Questions* section for more info on common problems.\n\nThis is a Python port of ``Text::Unidecode`` Perl module by Sean M. Burke\n\u003csburke@cpan.org\u003e.\n\n\nModule content\n--------------\n\nThis library contains a function that takes a string object, possibly\ncontaining non-ASCII characters, and returns a string that can be safely\nencoded to ASCII::\n\n    \u003e\u003e\u003e from unidecode import unidecode\n    \u003e\u003e\u003e unidecode('kožušček')\n    'kozuscek'\n    \u003e\u003e\u003e unidecode('30 \\U0001d5c4\\U0001d5c6/\\U0001d5c1')\n    '30 km/h'\n    \u003e\u003e\u003e unidecode('\\u5317\\u4EB0')\n    'Bei Jing '\n\nYou can also specify an *errors* argument to ``unidecode()`` that determines\nwhat Unidecode does with characters that are not present in its transliteration\ntables. The default is ``'ignore'`` meaning that Unidecode will ignore those\ncharacters (replace them with an empty string). ``'strict'`` will raise a\n``UnidecodeError``. The exception object will contain an *index* attribute that\ncan be used to find the offending character. ``'replace'`` will replace them\nwith ``'?'`` (or another string, specified in the *replace_str* argument).\n``'preserve'`` will keep the original, non-ASCII character in the string. Note\nthat if ``'preserve'`` is used the string returned by ``unidecode()`` will not\nbe ASCII-encodable!::\n\n    \u003e\u003e\u003e unidecode('\\ue000') # unidecode does not have replacements for Private Use Area characters\n    ''\n    \u003e\u003e\u003e unidecode('\\ue000', errors='strict')\n    Traceback (most recent call last):\n    ...\n    unidecode.UnidecodeError: no replacement found for character '\\ue000' in position 0\n\nA utility is also included that allows you to transliterate text from the\ncommand line in several ways. Reading from standard input::\n\n    $ echo hello | unidecode\n    hello\n\nfrom a command line argument::\n\n    $ unidecode -c hello\n    hello\n\nor from a file::\n\n    $ unidecode hello.txt\n    hello\n\nThe default encoding used by the utility depends on your system locale. You can\nspecify another encoding with the ``-e`` argument. See ``unidecode --help`` for\na full list of available options.\n\nRequirements\n------------\n\nNothing except Python itself. Unidecode supports Python 3.7 or later.\n\nYou need a Python build with \"wide\" Unicode characters (also called \"UCS-4\nbuild\") in order for Unidecode to work correctly with characters outside of\nBasic Multilingual Plane (BMP). Common characters outside BMP are bold, italic,\nscript, etc. variants of the Latin alphabet intended for mathematical notation.\nSurrogate pair encoding of \"narrow\" builds is not supported in Unidecode.\n\nIf your Python build supports \"wide\" Unicode the following expression will\nreturn True::\n\n    \u003e\u003e\u003e import sys\n    \u003e\u003e\u003e sys.maxunicode \u003e 0xffff\n    True\n\nSee `PEP 261 \u003chttps://www.python.org/dev/peps/pep-0261/\u003e`_ for details\nregarding support for \"wide\" Unicode characters in Python.\n\n\nInstallation\n------------\n\nTo install the latest version of Unidecode from the Python package index, use\nthese commands::\n\n    $ pip install unidecode\n\nTo install Unidecode from the source distribution and run unit tests, use::\n\n    $ python setup.py install\n    $ python setup.py test\n\nFrequently asked questions\n--------------------------\n\nGerman umlauts are transliterated incorrectly\n    Latin letters \"a\", \"o\" and \"u\" with diaeresis are transliterated by\n    Unidecode as \"a\", \"o\", \"u\", *not* according to German rules \"ae\", \"oe\",\n    \"ue\". This is intentional and will not be changed. Rationale is that these\n    letters are used in languages other than German (for example, Finnish and\n    Turkish). German text transliterated without the extra \"e\" is much more\n    readable than other languages transliterated using German rules. A\n    workaround is to do your own replacements of these characters before\n    passing the string to ``unidecode()``.\n\nJapanese Kanji is transliterated as Chinese\n    Same as with Latin letters with accents discussed in the answer above, the\n    Unicode standard encodes letters, not letters in a certain language or\n    their meaning. With Japanese and Chinese this is even more evident because\n    the same letter can have very different transliterations depending on the\n    language it is used in. Since Unidecode does not do language-specific\n    transliteration (see next question), it must decide on one. For certain\n    characters that are used in both Japanese and Chinese the decision was to\n    use Chinese transliterations. If you intend to transliterate Japanese,\n    Chinese or Korean text please consider using other libraries which do\n    language-specific transliteration, such as `Unihandecode\n    \u003chttps://github.com/miurahr/unihandecode\u003e`_.\n\nUnidecode should support localization (e.g. a language or country parameter, inspecting system locale, etc.)\n    Language-specific transliteration is a complicated problem and beyond the\n    scope of this library. Changes related to this will not be accepted. Please\n    consider using other libraries which do provide this capability, such as\n    `Unihandecode \u003chttps://github.com/miurahr/unihandecode\u003e`_.\n\nUnidecode should automatically detect the language of the text being transliterated\n    Language detection is a completely separate problem and beyond the scope of\n    this library.\n\nUnidecode should use a permissive license such as MIT or the BSD license.\n    The maintainer of Unidecode believes that providing access to source code\n    on redistribution is a fair and reasonable request when basing products on\n    voluntary work of many contributors. If the license is not suitable for\n    you, please consider using other libraries, such as `text-unidecode\n    \u003chttps://github.com/kmike/text-unidecode\u003e`_.\n\nUnidecode produces completely wrong results (e.g. \"u\" with diaeresis transliterating as \"A 1/4 \")\n    The strings you are passing to Unidecode have been wrongly decoded\n    somewhere in your program. For example, you might be decoding utf-8 encoded\n    strings as latin1. With a misconfigured terminal, locale and/or a text\n    editor this might not be immediately apparent. Inspect your strings with\n    ``repr()`` and consult the\n    `Unicode HOWTO \u003chttps://docs.python.org/3/howto/unicode.html\u003e`_.\n\nWhy does Unidecode not replace \\\\u and \\\\U backslash escapes in my strings?\n    Unidecode knows nothing about escape sequences. Interpreting these sequences\n    and replacing them with actual Unicode characters in string literals is the\n    task of the Python interpreter. If you are asking this question you are\n    very likely misunderstanding the purpose of this library. Consult the\n    `Unicode HOWTO \u003chttps://docs.python.org/3/howto/unicode.html\u003e`_ and possibly\n    the ``unicode_escape`` encoding in the standard library.\n\nI've upgraded Unidecode and now some URLs on my website return 404 Not Found.\n    This is an issue with the software that is running your website, not\n    Unidecode. Occasionally, new versions of Unidecode library are released\n    which contain improvements to the transliteration tables. This means that\n    you cannot rely that ``unidecode()`` output will not change across\n    different versions of Unidecode library. If you use ``unidecode()`` to\n    generate URLs for your website, either generate the URL slug once and store\n    it in the database or lock your dependency of Unidecode to one specific\n    version.\n\nSome of the issues in this section are discussed in more detail in `this blog\npost \u003chttps://www.tablix.org/~avian/blog/archives/2013/09/python_unidecode_release_0_04_14/\u003e`_.\n\n\nPerformance notes\n-----------------\n\nBy default, ``unidecode()`` optimizes for the use case where most of the strings\npassed to it are already ASCII-only and no transliteration is necessary (this\ndefault might change in future versions).\n\nFor performance critical applications, two additional functions are exposed:\n\n``unidecode_expect_ascii()`` is optimized for ASCII-only inputs (approximately\n5 times faster than ``unidecode_expect_nonascii()`` on 10 character strings,\nmore on longer strings), but slightly slower for non-ASCII inputs.\n\n``unidecode_expect_nonascii()`` takes approximately the same amount of time on\nASCII and non-ASCII inputs, but is slightly faster for non-ASCII inputs than\n``unidecode_expect_ascii()``.\n\nApart from differences in run time, both functions produce identical results.\nFor most users of Unidecode, the difference in performance should be\nnegligible.\n\n\nSource\n------\n\nYou can get the latest development version of Unidecode with::\n\n    $ git clone https://www.tablix.org/~avian/git/unidecode.git\n\nThere is also an official mirror of this repository on GitHub at\nhttps://github.com/avian2/unidecode\n\n\nContact\n-------\n\nPlease make sure to read the `Frequently asked questions`_ section above before\ncontacting the maintainer.\n\nBug reports, patches and suggestions for Unidecode can be sent to\ntomaz.solc@tablix.org.\n\nAlternatively, you can also open a ticket or pull request at\nhttps://github.com/avian2/unidecode\n\n\nCopyright\n---------\n\nOriginal character transliteration tables:\n\nCopyright 2001, Sean M. Burke \u003csburke@cpan.org\u003e, all rights reserved.\n\nPython code and later additions:\n\nCopyright 2026, Tomaž Šolc \u003ctomaz.solc@tablix.org\u003e\n\nThis program is free software; you can redistribute it and/or modify it\nunder the terms of the GNU General Public License as published by the Free\nSoftware Foundation; either version 2 of the License, or (at your option)\nany later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT\nANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\nmore details.\n\nYou should have received a copy of the GNU General Public License along\nwith this program; if not, write to the Free Software Foundation, Inc., 51\nFranklin Street, Fifth Floor, Boston, MA 02110-1301 USA.  The programs and\ndocumentation in this dist are distributed in the hope that they will be\nuseful, but without any warranty; without even the implied warranty of\nmerchantability or fitness for a particular purpose.\n\n..\n    vim: set filetype=rst:\n","funding_links":[],"categories":["Python","Text Processing","Feature Extraction"],"sub_categories":["Text/NLP"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favian2%2Funidecode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favian2%2Funidecode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favian2%2Funidecode/lists"}