aaronhktan / hkscs-unicode-converter

hkscs-unicode-converter is a Python package for converting HKSCS characters assigned to Private Use Areas of Unicode to their equivalents in Unicode 4.1 onwards.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hkscs-unicode-converter

hkscs-unicode-converter is a utility for converting HKSCS characters assigned to Private Use Areas of Unicode to their equivalents in Unicode 4.1 onwards. Inspired by the npm module of the same name.

>>> from hkscs_unicode_converter import converter
>>> converter.convert_string("亂廿四") # Convert an entire string
'亂噏廿四'
>>> converter.convert_char("") # Convert a single character
'嘅'
>>> converter.convert_char(chr(0xE7D4)) # Convert from codepoint
'啱'
>>> converter.convert_char("\uE7D4") # Convert from Unicode literal
'啱'
>>> hex(ord(converter.convert_char(chr(0xE7D4)))) # Get corresponding codepoint
'0x5571'

Installing

hkscs-unicode-converter is available on PyPI and officially supports Python 3.7+:

$ python3 -m pip install hkscs-unicode-converter

Tests

Tests are located in the hkscs_unicode_converter submodule. Testing uses tox to automate environment management and the built-in unittest framework to run tests.

$ tox

Style Guide

Run black before committing to master!

About

hkscs-unicode-converter is a Python package for converting HKSCS characters assigned to Private Use Areas of Unicode to their equivalents in Unicode 4.1 onwards.

License:MIT License


Languages

Language:Python 100.0%