# pyunormalize
A pure Python implementation of the **Unicode normalization algorithm** independent from the Python core Unicode database. This package supports version 15.1 of the Unicode standard (released in September 2023). It has been thoroughly tested against the [Unicode test file](https://www.unicode.org/Public/15.1.0/ucd/NormalizationTest.txt).
For the formal specification of the Unicode normalization algorithm, see [Section 3.11, Normalization Forms](https://www.unicode.org/versions/Unicode15.1.0/ch03.pdf#G49537), in the Unicode core specification.
### Installation
The easiest method to install is using pip:
```shell
pip install pyunormalize
```
### UCD version
To get the version of the Unicode character database currently used:
```python
>>> from pyunormalize import UCD_VERSION
>>> UCD_VERSION
'15.1.0'
```
### Example usage
```python
>>> from pyunormalize import NFC, NFD, NFKC, NFKD
>>> s = "élève" # "\u00E9\u006C\u00E8\u0076\u0065"
>>> nfc = NFC(s)
>>> nfd = NFD(s)
>>> nfc == s
True
>>> nfd == nfc
False
>>> " ".join([f"{ord(x):04X}" for x in nfc])
'00E9 006C 00E8 0076 0065'
>>> " ".join([f"{ord(x):04X}" for x in nfd])
'0065 0301 006C 0065 0300 0076 0065'
>>>
>>> s = "⑴ ffi ²"
>>> NFC(s), NFKC(s), NFD(s), NFKD(s)
('⑴ ffi ²', '(1) ffi 2', '⑴ ffi ²', '(1) ffi 2')
>>> from pyunormalize import normalize
>>> normalize("NFKD", "⑴ ffi ²")
'(1) ffi 2'
>>> forms = ["NFC", "NFD", "NFKC", "NFKD"]
>>> [normalize(f, "\u017F\u0307\u0323") for f in forms]
['ẛ̣', 'ẛ̣', 'ṩ', 'ṩ']
```
### Related resources
This implementation is based on the following resources:
- [Section 3.11, Normalization Forms, in the Unicode core specification, version 15.1.0](https://www.unicode.org/versions/Unicode15.1.0/ch03.pdf#G49537)
- [Unicode Standard Annex #15: Unicode Normalization Forms, version 54](https://www.unicode.org/reports/tr15/tr15-54.html)
### Licenses
The code is available under the [MIT license](https://github.com/mlodewijck/pyunormalize/blob/master/LICENSE).
Usage of Unicode data files is governed by the [UNICODE TERMS OF USE](https://www.unicode.org/copyright.html). Further specifications of rights and restrictions pertaining to the use of the Unicode data files and software can be found in the [Unicode Data Files and Software License](https://www.unicode.org/license.txt), a copy of which is included as [UNICODE-LICENSE](https://github.com/mlodewijck/pyunormalize/blob/master/UNICODE-LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/mlodewijck/pyunormalize",
"name": "pyunormalize-micropip",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "Unicode, Unicode data, Unicode normalization, normalization, NFC, NFD, NFKC, NFKD, Unicode Normalization Forms, Canonical Ordering Algorithm, Canonical Composition Algorithm, canonical ordering, canonical composition, Hangul Syllable Composition Algorithm, Hangul Syllable Decomposition Algorithm, Hangul syllables, Hangul jamo characters",
"author": "Marc Lodewijck",
"author_email": "mlodewijck@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/92/69/7ead22afe17c7baba6134939011de65fd2cc8c7d4b6f87f7eedd4fbaad5c/pyunormalize_micropip-15.1.0.tar.gz",
"platform": null,
"description": "# pyunormalize\nA pure Python implementation of the **Unicode normalization algorithm** independent from the Python core Unicode database. This package supports version 15.1 of the Unicode standard (released in September 2023). It has been thoroughly tested against the [Unicode test file](https://www.unicode.org/Public/15.1.0/ucd/NormalizationTest.txt).\n\nFor the formal specification of the Unicode normalization algorithm, see [Section 3.11, Normalization Forms](https://www.unicode.org/versions/Unicode15.1.0/ch03.pdf#G49537), in the Unicode core specification.\n\n### Installation\nThe easiest method to install is using pip:\n```shell\npip install pyunormalize\n```\n\n### UCD version\nTo get the version of the Unicode character database currently used:\n```python\n>>> from pyunormalize import UCD_VERSION\n>>> UCD_VERSION\n'15.1.0'\n```\n\n### Example usage\n```python\n>>> from pyunormalize import NFC, NFD, NFKC, NFKD\n>>> s = \"\u00e9l\u00e8ve\" # \"\\u00E9\\u006C\\u00E8\\u0076\\u0065\"\n>>> nfc = NFC(s)\n>>> nfd = NFD(s)\n>>> nfc == s\nTrue\n>>> nfd == nfc\nFalse\n>>> \" \".join([f\"{ord(x):04X}\" for x in nfc])\n'00E9 006C 00E8 0076 0065'\n>>> \" \".join([f\"{ord(x):04X}\" for x in nfd])\n'0065 0301 006C 0065 0300 0076 0065'\n>>>\n>>> s = \"\u2474 \ufb03 \u00b2\"\n>>> NFC(s), NFKC(s), NFD(s), NFKD(s)\n('\u2474 \ufb03 \u00b2', '(1) ffi 2', '\u2474 \ufb03 \u00b2', '(1) ffi 2')\n\n>>> from pyunormalize import normalize\n>>> normalize(\"NFKD\", \"\u2474 \ufb03 \u00b2\")\n'(1) ffi 2'\n>>> forms = [\"NFC\", \"NFD\", \"NFKC\", \"NFKD\"]\n>>> [normalize(f, \"\\u017F\\u0307\\u0323\") for f in forms]\n['\u1e9b\u0323', '\u017f\u0323\u0307', '\u1e69', 's\u0323\u0307']\n```\n\n### Related resources\nThis implementation is based on the following resources:\n- [Section 3.11, Normalization Forms, in the Unicode core specification, version 15.1.0](https://www.unicode.org/versions/Unicode15.1.0/ch03.pdf#G49537)\n- [Unicode Standard Annex #15: Unicode Normalization Forms, version 54](https://www.unicode.org/reports/tr15/tr15-54.html)\n\n### Licenses\nThe code is available under the [MIT license](https://github.com/mlodewijck/pyunormalize/blob/master/LICENSE).\n\nUsage of Unicode data files is governed by the [UNICODE TERMS OF USE](https://www.unicode.org/copyright.html). Further specifications of rights and restrictions pertaining to the use of the Unicode data files and software can be found in the [Unicode Data Files and Software License](https://www.unicode.org/license.txt), a copy of which is included as [UNICODE-LICENSE](https://github.com/mlodewijck/pyunormalize/blob/master/UNICODE-LICENSE).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Unicode normalization forms (NFC, NFKC, NFD, NFKD). A library independent from the Python core Unicode database.",
"version": "15.1.0",
"project_urls": {
"Bug Reports": "https://github.com/mlodewijck/pyunormalize/issues",
"Homepage": "https://github.com/mlodewijck/pyunormalize",
"Source": "https://github.com/mlodewijck/pyunormalize/"
},
"split_keywords": [
"unicode",
" unicode data",
" unicode normalization",
" normalization",
" nfc",
" nfd",
" nfkc",
" nfkd",
" unicode normalization forms",
" canonical ordering algorithm",
" canonical composition algorithm",
" canonical ordering",
" canonical composition",
" hangul syllable composition algorithm",
" hangul syllable decomposition algorithm",
" hangul syllables",
" hangul jamo characters"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f3f0c73d9a51d1bab11112f70cb88feff3613f244a3905018dff30c46c79412d",
"md5": "4dbf9b741639498e27d4df22e5798027",
"sha256": "2e9d54d29af940a5b3a1fb13d4520ec2082f0853f5fec8869dc03885a62c5d5b"
},
"downloads": -1,
"filename": "pyunormalize_micropip-15.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4dbf9b741639498e27d4df22e5798027",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 516136,
"upload_time": "2024-06-08T13:02:43",
"upload_time_iso_8601": "2024-06-08T13:02:43.003465Z",
"url": "https://files.pythonhosted.org/packages/f3/f0/c73d9a51d1bab11112f70cb88feff3613f244a3905018dff30c46c79412d/pyunormalize_micropip-15.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "92697ead22afe17c7baba6134939011de65fd2cc8c7d4b6f87f7eedd4fbaad5c",
"md5": "1c278782bbee77d2cb6420d70f612a4a",
"sha256": "56ec783f561546b95ff3c8a90ccdc8f1461f6be71facef27c53e77d50dedb2fd"
},
"downloads": -1,
"filename": "pyunormalize_micropip-15.1.0.tar.gz",
"has_sig": false,
"md5_digest": "1c278782bbee77d2cb6420d70f612a4a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 515289,
"upload_time": "2024-06-08T13:02:46",
"upload_time_iso_8601": "2024-06-08T13:02:46.300778Z",
"url": "https://files.pythonhosted.org/packages/92/69/7ead22afe17c7baba6134939011de65fd2cc8c7d4b6f87f7eedd4fbaad5c/pyunormalize_micropip-15.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-08 13:02:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mlodewijck",
"github_project": "pyunormalize",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pyunormalize-micropip"
}