Python bindings for ICU4C
Project description
icupy
Python bindings for ICU4C.
Installation
Prerequisites
- Python >=3.8, <4
- ICU4C (>=64 recommended)
- C++17 compatible compiler (depends on pybind11)
- CMake >=3.7
Building from source
-
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. -
Cloning the repository and using pip to install.
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
Release history Release notifications | RSS feed
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.1.0.tar.gz
(255.7 kB
view details)
File details
Details for the file icupy-0.1.0.tar.gz
.
File metadata
- Download URL: icupy-0.1.0.tar.gz
- Upload date:
- Size: 255.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea52f414e4e9028df0e1ebf60c438b0886bdb7a9d3fd2575d048bbd9781bf8e7 |
|
MD5 | b6bd16fff8f8ce45be9cb2c32aa5760a |
|
BLAKE2b-256 | 0e21f40601c7cd3378167f9d7d45c6605afa036678eae75a7382cf5f0b402ecf |