PyICU Binary

2.7.4 · active · verified Thu Apr 16

PyICU-binary (version 2.7.4) is a Python package that provides pre-built wheels for PyICU, a Python extension wrapping the ICU C++ API. ICU (International Components for Unicode) offers robust Unicode and internationalization services. This binary distribution aims to simplify installation by providing ready-to-use wheels for various platforms, bypassing the often complex process of compiling PyICU against a separately installed ICU library. While the upstream PyICU project sees regular updates, `pyicu-binary` releases track the upstream project as compatible binaries are built.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic locale creation, retrieving locale display names, and using a `Collator` for locale-aware string sorting, which is a common use case for ICU.

import icu

# Get the default locale
default_locale = icu.Locale.getDefault()
print(f"Default Locale: {default_locale.getDisplayName()}")

# Create a specific locale and get its display name in the default locale
japanese_locale = icu.Locale("ja_JP")
print(f"Japanese Locale Display Name: {japanese_locale.getDisplayName(default_locale)}")

# Perform collation (sorting) using a specific locale
collator = icu.Collator.createInstance(japanese_locale)
words = ["りんご", "みかん", "バナナ"]
sorted_words = sorted(words, key=collator.getSortKey)
print(f"Sorted Japanese words: {sorted_words}")

view raw JSON →