{"id":13634472,"url":"https://github.com/kjd/idna","last_synced_at":"2025-05-14T18:06:01.981Z","repository":{"id":8667398,"uuid":"10323585","full_name":"kjd/idna","owner":"kjd","description":"Internationalized Domain Names for Python (IDNA 2008 and UTS #46)","archived":false,"fork":false,"pushed_at":"2025-05-02T02:38:56.000Z","size":1025,"stargazers_count":260,"open_issues_count":4,"forks_count":102,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-05-08T00:02:02.474Z","etag":null,"topics":["dns","hacktoberfest","idna","python","unicode"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kjd.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-05-27T22:22:13.000Z","updated_at":"2025-05-02T02:16:34.000Z","dependencies_parsed_at":"2022-08-08T09:15:10.651Z","dependency_job_id":"d66f9eee-f9a6-4248-aea5-eda8990e28a3","html_url":"https://github.com/kjd/idna","commit_stats":{"total_commits":275,"total_committers":28,"mean_commits":9.821428571428571,"dds":0.7345454545454546,"last_synced_commit":"384f16825ef92cc08bb7e11bd42427bdaf87401d"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjd%2Fidna","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjd%2Fidna/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjd%2Fidna/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjd%2Fidna/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kjd","download_url":"https://codeload.github.com/kjd/idna/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252973691,"owners_count":21834108,"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":["dns","hacktoberfest","idna","python","unicode"],"created_at":"2024-08-01T23:01:05.781Z","updated_at":"2025-05-14T18:06:01.934Z","avatar_url":"https://github.com/kjd.png","language":"Python","readme":"Internationalized Domain Names in Applications (IDNA)\n=====================================================\n\nSupport for the Internationalized Domain Names in\nApplications (IDNA) protocol as specified in `RFC 5891\n\u003chttps://tools.ietf.org/html/rfc5891\u003e`_. This is the latest version of\nthe protocol and is sometimes referred to as “IDNA 2008”.\n\nThis library also provides support for Unicode Technical\nStandard 46, `Unicode IDNA Compatibility Processing\n\u003chttps://unicode.org/reports/tr46/\u003e`_.\n\nThis acts as a suitable replacement for the “encodings.idna”\nmodule that comes with the Python standard library, but which\nonly supports the older superseded IDNA specification (`RFC 3490\n\u003chttps://tools.ietf.org/html/rfc3490\u003e`_).\n\nBasic functions are simply executed:\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e import idna\n    \u003e\u003e\u003e idna.encode('ドメイン.テスト')\n    b'xn--eckwd4c7c.xn--zckzah'\n    \u003e\u003e\u003e print(idna.decode('xn--eckwd4c7c.xn--zckzah'))\n    ドメイン.テスト\n\n\nInstallation\n------------\n\nThis package is available for installation from PyPI:\n\n.. code-block:: bash\n\n    $ python3 -m pip install idna\n\n\nUsage\n-----\n\nFor typical usage, the ``encode`` and ``decode`` functions will take a\ndomain name argument and perform a conversion to A-labels or U-labels\nrespectively.\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e import idna\n    \u003e\u003e\u003e idna.encode('ドメイン.テスト')\n    b'xn--eckwd4c7c.xn--zckzah'\n    \u003e\u003e\u003e print(idna.decode('xn--eckwd4c7c.xn--zckzah'))\n    ドメイン.テスト\n\nYou may use the codec encoding and decoding methods using the\n``idna.codec`` module:\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e import idna.codec\n    \u003e\u003e\u003e print('домен.испытание'.encode('idna2008'))\n    b'xn--d1acufc.xn--80akhbyknj4f'\n    \u003e\u003e\u003e print(b'xn--d1acufc.xn--80akhbyknj4f'.decode('idna2008'))\n    домен.испытание\n\nConversions can be applied at a per-label basis using the ``ulabel`` or\n``alabel`` functions if necessary:\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e idna.alabel('测试')\n    b'xn--0zwm56d'\n\nCompatibility Mapping (UTS #46)\n+++++++++++++++++++++++++++++++\n\nAs described in `RFC 5895 \u003chttps://tools.ietf.org/html/rfc5895\u003e`_, the\nIDNA specification does not normalize input from different potential\nways a user may input a domain name. This functionality, known as\na “mapping”, is considered by the specification to be a local\nuser-interface issue distinct from IDNA conversion functionality.\n\nThis library provides one such mapping that was developed by the\nUnicode Consortium. Known as `Unicode IDNA Compatibility Processing\n\u003chttps://unicode.org/reports/tr46/\u003e`_, it provides for both a regular\nmapping for typical applications, as well as a transitional mapping to\nhelp migrate from older IDNA 2003 applications. Strings are\npreprocessed according to Section 4.4 “Preprocessing for IDNA2008”\nprior to the IDNA operations.\n\nFor example, “Königsgäßchen” is not a permissible label as *LATIN\nCAPITAL LETTER K* is not allowed (nor are capital letters in general).\nUTS 46 will convert this into lower case prior to applying the IDNA\nconversion.\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e import idna\n    \u003e\u003e\u003e idna.encode('Königsgäßchen')\n    ...\n    idna.core.InvalidCodepoint: Codepoint U+004B at position 1 of 'Königsgäßchen' not allowed\n    \u003e\u003e\u003e idna.encode('Königsgäßchen', uts46=True)\n    b'xn--knigsgchen-b4a3dun'\n    \u003e\u003e\u003e print(idna.decode('xn--knigsgchen-b4a3dun'))\n    königsgäßchen\n\nTransitional processing provides conversions to help transition from\nthe older 2003 standard to the current standard. For example, in the\noriginal IDNA specification, the *LATIN SMALL LETTER SHARP S* (ß) was\nconverted into two *LATIN SMALL LETTER S* (ss), whereas in the current\nIDNA specification this conversion is not performed.\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e idna.encode('Königsgäßchen', uts46=True, transitional=True)\n    'xn--knigsgsschen-lcb0w'\n\nImplementers should use transitional processing with caution, only in\nrare cases where conversion from legacy labels to current labels must be\nperformed (i.e. IDNA implementations that pre-date 2008). For typical\napplications that just need to convert labels, transitional processing\nis unlikely to be beneficial and could produce unexpected incompatible\nresults.\n\n``encodings.idna`` Compatibility\n++++++++++++++++++++++++++++++++\n\nFunction calls from the Python built-in ``encodings.idna`` module are\nmapped to their IDNA 2008 equivalents using the ``idna.compat`` module.\nSimply substitute the ``import`` clause in your code to refer to the new\nmodule name.\n\nExceptions\n----------\n\nAll errors raised during the conversion following the specification\nshould raise an exception derived from the ``idna.IDNAError`` base\nclass.\n\nMore specific exceptions that may be generated as ``idna.IDNABidiError``\nwhen the error reflects an illegal combination of left-to-right and\nright-to-left characters in a label; ``idna.InvalidCodepoint`` when\na specific codepoint is an illegal character in an IDN label (i.e.\nINVALID); and ``idna.InvalidCodepointContext`` when the codepoint is\nillegal based on its positional context (i.e. it is CONTEXTO or CONTEXTJ\nbut the contextual requirements are not satisfied.)\n\nBuilding and Diagnostics\n------------------------\n\nThe IDNA and UTS 46 functionality relies upon pre-calculated lookup\ntables for performance. These tables are derived from computing against\neligibility criteria in the respective standards. These tables are\ncomputed using the command-line script ``tools/idna-data``.\n\nThis tool will fetch relevant codepoint data from the Unicode repository\nand perform the required calculations to identify eligibility. There are\nthree main modes:\n\n* ``idna-data make-libdata``. Generates ``idnadata.py`` and\n  ``uts46data.py``, the pre-calculated lookup tables used for IDNA and\n  UTS 46 conversions. Implementers who wish to track this library against\n  a different Unicode version may use this tool to manually generate a\n  different version of the ``idnadata.py`` and ``uts46data.py`` files.\n\n* ``idna-data make-table``. Generate a table of the IDNA disposition\n  (e.g. PVALID, CONTEXTJ, CONTEXTO) in the format found in Appendix\n  B.1 of RFC 5892 and the pre-computed tables published by `IANA\n  \u003chttps://www.iana.org/\u003e`_.\n\n* ``idna-data U+0061``. Prints debugging output on the various\n  properties associated with an individual Unicode codepoint (in this\n  case, U+0061), that are used to assess the IDNA and UTS 46 status of a\n  codepoint. This is helpful in debugging or analysis.\n\nThe tool accepts a number of arguments, described using ``idna-data\n-h``. Most notably, the ``--version`` argument allows the specification\nof the version of Unicode to be used in computing the table data. For\nexample, ``idna-data --version 9.0.0 make-libdata`` will generate\nlibrary data against Unicode 9.0.0.\n\n\nAdditional Notes\n----------------\n\n* **Packages**. The latest tagged release version is published in the\n  `Python Package Index \u003chttps://pypi.org/project/idna/\u003e`_.\n\n* **Version support**. This library supports Python 3.6 and higher.\n  As this library serves as a low-level toolkit for a variety of\n  applications, many of which strive for broad compatibility with older\n  Python versions, there is no rush to remove older interpreter support.\n  Removing support for older versions should be well justified in that the\n  maintenance burden has become too high.\n\n* **Python 2**. Python 2 is supported by version 2.x of this library.\n  Use \"idna\u003c3\" in your requirements file if you need this library for\n  a Python 2 application. Be advised that these versions are no longer\n  actively developed.\n\n* **Testing**. The library has a test suite based on each rule of the\n  IDNA specification, as well as tests that are provided as part of the\n  Unicode Technical Standard 46, `Unicode IDNA Compatibility Processing\n  \u003chttps://unicode.org/reports/tr46/\u003e`_.\n\n* **Emoji**. It is an occasional request to support emoji domains in\n  this library. Encoding of symbols like emoji is expressly prohibited by\n  the technical standard IDNA 2008 and emoji domains are broadly phased\n  out across the domain industry due to associated security risks. For\n  now, applications that need to support these non-compliant labels\n  may wish to consider trying the encode/decode operation in this library\n  first, and then falling back to using `encodings.idna`. See `the Github\n  project \u003chttps://github.com/kjd/idna/issues/18\u003e`_ for more discussion.\n","funding_links":[],"categories":["Others","Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkjd%2Fidna","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkjd%2Fidna","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkjd%2Fidna/lists"}