Skip to main content

Python bindings for ICU4C

Project description

icupy

Python bindings for ICU4C.

Installation

Prerequisites

Building from source

  1. If on Windows or ICU is located in a non-regular place, set the ICU_ROOT environment variable to the root of the ICU installation.

  2. Installing from PyPI:

    pip install icupy
    

    Alternatively, installing from the git repository:

    git clone --recursive https://github.com/miute/icupy.git
    pip install ./icupy
    

Notes

  • Changed C function name and class method name from camel case to snake case.

Examples

  • icu::UnicodeString with error callback

    >>> import icupy as icu
    >>> cnv = icu.ucnv_open("utf-8")
    >>> action = icu.UCNV_TO_U_CALLBACK_ESCAPE
    >>> context = icu.ConstVoidPtr(icu.UCNV_ESCAPE_C)
    >>> icu.ucnv_set_to_u_call_back(cnv, action, context)
    >>> utf8 = b"\x61\xfe\x62"  # Impossible bytes
    >>> s = icu.UnicodeString(utf8, -1, cnv)
    >>> str(s)
    'a\\xFEb'
    
  • icu::IDNA (UTS #46)

    >>> import icupy as icu
    >>> uts46 = icu.IDNA.create_uts46_instance(icu.IDNA.NONTRANSITIONAL_TO_ASCII)
    >>> dest = icu.UnicodeString()
    >>> info = icu.IDNAInfo()
    >>> uts46.name_to_ascii(icu.UnicodeString("faß.ExAmPlE"), dest, info)
    >>> str(dest)
    'xn--fa-hia.example'
    
  • See also tests directory.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

icupy-0.5.0.tar.gz (284.4 kB view details)

Uploaded Source

File details

Details for the file icupy-0.5.0.tar.gz.

File metadata

  • Download URL: icupy-0.5.0.tar.gz
  • Upload date:
  • Size: 284.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.7

File hashes

Hashes for icupy-0.5.0.tar.gz
Algorithm Hash digest
SHA256 0b35709997be6176453d930d18ef058ef83d3d5d16490f7b982bc7eb2ba9aadf
MD5 219a24627eaaf580d98c80af38b416ac
BLAKE2b-256 1c836f07a5322c9cc8dbb17ef091bebc4f2c8832c2af958f85f30fa49451e081

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page