{"id":5544,"library":"unicodedata2","title":"unicodedata2","description":"unicodedata2 is a backport of the `unicodedata` module from the Python standard library, updated to include the latest Unicode versions. It provides access to the Unicode character database, enabling functions like querying character properties (name, category, numeric value) and normalizing Unicode strings. The current version is 17.0.1, and it typically releases new major versions to align with updates to the Unicode standard.","status":"active","version":"17.0.1","language":"en","source_language":"en","source_url":"https://github.com/fonttools/unicodedata2","tags":["unicode","string processing","internationalization","i18n","backport"],"install":[{"cmd":"pip install unicodedata2","lang":"bash","label":"Install unicodedata2"}],"dependencies":[],"imports":[{"note":"To use the updated Unicode database provided by this library, you must explicitly import `unicodedata2`. Importing `unicodedata` will use the standard library's built-in module, which is tied to your Python version's Unicode data, not `unicodedata2`'s.","wrong":"import unicodedata","symbol":"unicodedata2","correct":"import unicodedata2"}],"quickstart":{"code":"import unicodedata2\n\n# Get character name\nchar = 'é'\nname = unicodedata2.name(char)\nprint(f\"Character: '{char}', Name: {name}\")\n\n# Get character category\ncategory = unicodedata2.category(char)\nprint(f\"Category for '{char}': {category}\")\n\n# Normalize a Unicode string\ns1 = 'café'\ns2 = 'cafe\\u0301' # 'e' followed by combining acute accent\n\nprint(f\"String 1: '{s1}', String 2: '{s2}'\")\nprint(f\"Are they equal? {s1 == s2}\")\n\nnormalized_s1 = unicodedata2.normalize('NFC', s1)\nnormalized_s2 = unicodedata2.normalize('NFC', s2)\n\nprint(f\"Normalized S1 (NFC): '{normalized_s1}'\")\nprint(f\"Normalized S2 (NFC): '{normalized_s2}'\")\nprint(f\"Are they equal after NFC? {normalized_s1 == normalized_s2}\")","lang":"python","description":"This quickstart demonstrates how to import `unicodedata2` and use its core functions like `name()`, `category()`, and `normalize()` to inspect and process Unicode characters and strings. It highlights character properties and the importance of normalization for string comparison."},"warnings":[{"fix":"Review your code after upgrading `unicodedata2` for any logic dependent on precise Unicode character data. Test thoroughly against the new Unicode version to ensure compatibility.","message":"Major version updates (e.g., 17.0.0, 16.0.0) correspond to new Unicode Standard releases. Code relying on specific character properties or the existence of certain characters might behave differently or break with new Unicode versions due to additions, changes, or deprecations in the standard.","severity":"breaking","affected_versions":"All major version increments (e.g., 16.x.x to 17.x.x)"},{"fix":"Ensure your project runs on a currently supported Python version before upgrading `unicodedata2`. Check the library's release notes for specific Python version compatibility with each `unicodedata2` release.","message":"Support for End-of-Life (EOL) Python versions is periodically dropped. For example, version 14.0.0 dropped support for Python 2.7 and 3.5, and older versions removed support for Python 3.3 and 3.4.","severity":"breaking","affected_versions":"14.0.0 and later (for Python 2.7, 3.5). Other versions for earlier EOL Python versions."},{"fix":"Always use `import unicodedata2` in your code if you intend to leverage the more recent Unicode data. Some projects use `try...except ImportError: import unicodedata2 as unicodedata` as a fallback mechanism.","message":"The `unicodedata2` library does not automatically replace the standard library's `unicodedata` module. You must explicitly `import unicodedata2` to access the updated Unicode character database. If you `import unicodedata`, you will use the older, built-in data tied to your Python interpreter's version.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If encountering build errors with a newly released Python version, check the `unicodedata2` GitHub issues or release notes for patches. Consider pinning `unicodedata2` to an older version or using a slightly older Python patch release until an update is available.","message":"New Python versions might initially encounter build issues with `unicodedata2` until the library releases an update. For instance, there were initial problems building `unicodedata2` with Python 3.11 that were later resolved in version 15.0.0.","severity":"gotcha","affected_versions":"New Python minor versions upon their initial release (e.g., Python 3.11 prior to `unicodedata2` v15.0.0)."}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}