Skip to main content

query Unicode script metadata

Project description

Simple Python 3 module to query Unicode UCD script metadata (see UAX #24).

This module is useful for querying if a text is made of Latin characters, Arabic, hiragana, kanji (han), and so on. It works for all scripts supported by the Unicode character database.

This module is dumb and slow. If you need speed, you probably want to implement your own functions.

Sample usage:

>>> import uniscripts
>>> uniscripts.is_script('A', 'Latin')
True

# if you pass it a string, all characters must match
>>> uniscripts.is_script('はるはあけぼの', 'Hiragana')
True

>>> uniscripts.is_script('はるはAkebono', 'Hiragana')
False

# ...but by default, it ignores 'Common' characters, such as punctuation.
>>> uniscripts.is_script('はるは:あけぼの', 'Hiragana')
True

>>> uniscripts.is_script('中華人民共和国', 'Han') # 'Han' = kanji or hànzì
True

>>> uniscripts.which_scripts('z')
['Latin']

>>> uniscripts.which_scripts('は')
['Hiragana']

>>> uniscripts.which_scripts('ー') # U+30FC
['Common', 'Katakana', 'Hiragana', 'Hangul', 'Han', 'Bopomofo', 'Yi']

See docstrings for is_script(), which_scripts().

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

uniscripts-1.0.4.tar.gz (16.0 kB view details)

Uploaded Source

File details

Details for the file uniscripts-1.0.4.tar.gz.

File metadata

  • Download URL: uniscripts-1.0.4.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for uniscripts-1.0.4.tar.gz
Algorithm Hash digest
SHA256 bf1aa60184efca6b452ba3dabda68802c9d547e99fc3fcf07d702583dcd4c866
MD5 9597127c766f23a085fd3167f6000718
BLAKE2b-256 7e807e5e5a76b44b56821fd57ea6e5e065cbc30f9bec7136f53a18b53f25e846

See more details on using hashes here.

Supported by

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