Skip to main content

ucdinfo Module

Summary

This module contains various modules for interacting with Unicode data:

  • ucd Provides access to nearly all the properties and codepoints in the UCD. CJK is excluded for space reasons
  • ducet Gives a ducet sort key from a string
  • uax53 Applies UAX53 Arabic ordering to a string

ucd Usage

    from ucdinfo import get_ucd, get_info, find_ucd, get_enums
    print(get_ucd(0x0041, 'scx'))
    print(get_info(0x0041))
    print(get_enums("indic position"))
    print(find_ucd("indic position", "Bottom")

Note cjk properties are not supported for space reasons.

Data freshness and caching

The module ships with pre-built data. On first use this is checked against the current Unicode release (a single small request to unicode.org). If it is current it is copied to a per-user cache and not checked again for 30 days; if it is out of date, fresh data is downloaded and cached. Without network access whatever local data is available is used.

To never access the network (e.g. in a docker image), set:

UCDINFO_OFFLINE=1

The per-user cache is then used if there is one, otherwise the data shipped with the module.

If you want to use your own data file (perhaps the module data is stale) the use the object interface:

    from ucdinfo import UCD
    myucd = UCD(localfile="ucd.nounihan.flat.zip")   # localfile falls back to bundled data
    print(myucd.get(0x0041, 'scx'))

The second parameter specifies the property to be queried and can either be a property from https://www.unicode.org/reports/tr42, especially section 4.4 Properties, or the start of a full property name from that list.

For characters not yet in Unicode, data for additional characters can be temporarily appended to the bundled data:

    from ucdinfo import get_ucd, loadxml
    loadxml("extra-ucd.xml")

or, with the object interface:

    from ucdinfo import UCD
    myucd = UCD().loadxml("extra-ucd.xml")

The named file must be coded in the same form as the "flat" UCD XML data, though the only required character attributes are "cp" and anything needed by the calling process. For example:

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <ucd xmlns="http://www.unicode.org/ns/2003/ucd/1.0">
        <description>Some additional characters</description>
        <repertoire>
            <char cp="10EC2" age="16.0" gc="Lo" bc="AL" na="ARABIC LETTER DAL WITH TWO DOTS VERTICALLY BELOW"></char>
            <char cp="10EC3" age="16.0" gc="Lo" bc="AL" na="ARABIC LETTER TAH WITH TWO DOTS VERTICALLY BELOW"></char>
            <char cp="10EC4" age="16.0" gc="Lo" bc="AL" na="ARABIC LETTER KAF WITH TWO DOTS VERTICALLY BELOW"></char>
        </repertoire>
    </ucd>

ducet Usage

Just as the ucd module keeps its data up to date, so does the ducet module.

    from ucdinfo import get_sortkey, load_ducet
    sortkey = get_sortkey("A\u0300")
    print(str(sortkey))
    load_ducet("myallkeys.txt")     # to override the latest default

A SortKey is an enhanced list of keys. Lists can be compared to give collation ordering. A SortKey has attributes .primary, .secondary, .tertiary for the 3 subkeys.

uax53 Usage

This module has no data but uses the ucd module

    from ucdinfo import uax53
    res = uax53("\u0628\u064E\u0651\u0654")
    res == "\u0628\u0654\u0651\u064E"

Metadata

Release files for ucdinfo 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ucdinfo 0.3
File Size Uploaded Provenance Actions
ucdinfo-0.3.tar.gz 20.7 kB Without provenance Details for ucdinfo-0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ucdinfo 0.3
File Interpreter ABI Platform Actions
ucdinfo-0.3-py3-none-any.whl Python 3 none any Details for ucdinfo-0.3-py3-none-any.whl

Total release size: 416.0 kB

Release files / ucdinfo-0.3.tar.gz

Download URL ucdinfo-0.3.tar.gz
Size 20.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fa7d7f58b9961c2f732eb0eb5e79540cb5552c510d908b4f6020076825ee1b74
BLAKE2b-256 checksum
How to use checksums
50cd2614db87984a252718ad043b7621616597afece207af06cd85bd8bf49e87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / ucdinfo-0.3-py3-none-any.whl

Download URL ucdinfo-0.3-py3-none-any.whl
Size 395.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52f5c8867e2846aeb948e78fec92d5bf46b5b262016927e7648671c247c6a89d
BLAKE2b-256 checksum
How to use checksums
e2c82aced39a71077b952e208e4dac459b10f464ba29ae486a685c6e2d5ac799
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Security for ucdinfo 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page