Skip to main content

A unicode and character set explorer.

Project description

charex is a Unicode and character set explorer for understanding issues with character set translation and Unicode normalization.

Why Did I Make This?

I find the ambiguity of text data interesting. In memory it’s all ones and zeros. There is nothing inherent to the data that makes 0x20 mean a space character, but we’ve mostly agreed that it does. That “mostly” part is what’s interesting to me, and it’s where a lot of fun problems lie.

How Do I Use This?

It’s in PyPI, so you can install it with pip, as long as you are using Python 3.12 or higher:

pip install charex

charex has four modes of operation:

  • Direct command line invocation,

  • An interactive shell,

  • A graphical user interface (GUI),

  • An application programming interface (API).

Command Line

To get help for direct invocation from the command line:

$ charex -h

Interactive Shell

To launch the interactive shell:

$ charex

That will bring you to the charex shell:

Welcome to the charex shell.
Press ? for a list of comands.

charex>

From here you can type ? to see the list of available commands:

Welcome to the charex shell.
Press ? for a list of comands.

charex> ?
The following commands are available:

*  bl: Show the list of blocks.
*  cd: Decode the given address in all codecs.
*  ce: Encode the given character in all codecs.
*  cl: List registered character sets.
*  clear: Clear the terminal.
*  ct: Count denormalization results.
*  dm: Build a denormalization map.
*  dn: Perform denormalizations.
*  dt: Display details for a code point.
*  el: List the registered escape schemes.
*  es: Escape a string using the given scheme.
*  fl: List registered normalization forms.
*  gui: Start the GUI.
*  help: Display command list.
*  mf: Create emoji sequence for a region's flag.
*  nl: Perform normalizations.
*  ns: Show the list of named sequences.
*  pf: List characters with a given property value.
*  sh: Run in an interactive shell.
*  sv: Show the list of standardized variants.
*  up: List the Unicode properties.
*  uv: List the valid values for a Unicode property.
*  xt: Exit the charex shell.
*  zc: Show the list of emoji ZWJ sequence categories.
*  zl: Show the list of emoji ZWJ sequences.

For help on individual commands, use "help {command}".

charex>

And then type help then a name of one of the commands to learn what it does:

charex> help dn
usage: charex dn [-h] [-m MAXDEPTH] [-n NUMBER] [-r] [-s SEED] form base

Denormalize a string.

positional arguments:
  form                  The normalization form for the denormalization. Valid
                        options are: casefold, nfc, nfd, nfkc, nfkd.
  base                  The base normalized string.

options:
  -h, --help            show this help message and exit
  -m MAXDEPTH, --maxdepth MAXDEPTH
                        Maximum number of reverse normalizations to use for
                        each character.
  -n NUMBER, --number NUMBER
                        Maximum number of results to return.
  -r, --random          Randomize the denormalization.
  -s SEED, --seed SEED  Seed the randomized denormalization.

charex>

GUI

To launch the charex GUI:

$ charex gui

API

To import charex into your Python script to get a summary of a Unicode character:

>>> import charex
>>>
>>>
>>> value = 'a'
>>> char = charex.Character(value)
>>> print(char.summarize())
a U+0061 (LATIN SMALL LETTER A)

What Version of Unicode Does This Support?

Parts of charex rely on unicodedata in the Python Standard Library. This limits charex to supporting the version supported by the version of Python you are running. There may be a bit of a lag as new Python versions are released, but as of this release charex supports:

  • Python 3.12: Unicode 15.0

  • Python 3.13: Unicode 15.1

  • Python 3.14: Unicode 16.0

What happened to Unicode 14.0?

I have the dependencies I use to generate the documentation in the development dependencies. To support Unicode 14.0, I had to support Python 3.11. To support Python 3.11, I had to use an old version of Sphinx that has some vulnerabilities. To clean that up, I had to drop support for Python 3.11 and Unicode 14.0.

Is there a way I could have fixed it without dropping Python 3.11 support? Probably. It’s is something I’ll try to look into when I get time. If it’s a problem for anyone, I’ll try to prioritize it.

What Is Left To Do?

The following features are planned for the v0.2.5 or later releases:

  • Emoji combiner.

  • Basic doctests for all public classes and functions.

  • Web API.

  • Registration for character set codecs.

  • Allow unicode version switching.

The list of Unicode properties can be found here: Index

The list of Unihan properties is here: tr38

Changes in v0.2.4

The following are the changes in v0.2.4:

  • Updated dependencies.

  • Support for Unicode v16.0 for Python 3.14.

  • Added support for the InCB property to Unicode v15.1.

  • Removed official support for Python 3.11 to allow sphinx to be updated.

  • Added some checking to see if Unicode properties had been mapped.

  • Added alias_property() to the defined API.

  • Added zalgo (glitch) text escape.

  • Added the following commands:

    • bl: Shows the Unicode character blocks.

    • mf: Makes the flag for the given ISO 3166 region code,

    • zc: Lists the emoji ZWJ sequence categories.

Changes in v0.2.3

The following are the changes in v0.2.3:

  • Move dependency management to poetry.

  • Move package into /src directory.

  • Use tox for regression testing.

  • Support Unicode 15.0 for running under Python 3.12.

    • Add Unicode 15.0 files.

    • Added “kalternatetotalstrokes” property.

    • Moved “kcihait” property source.

    • Added “idna2008” property.

  • Support Unicode 15.1 for running under Python 3.13.

    • Add Unicode 15.1 files.

    • Remove seven Unihan properties.

      • kHKSCS

      • kIRGDaiKanwaZiten

      • kKPS0

      • kKPS1

      • kKSC0

      • kKSC1

      • kRSKangXi

    • Add six Unihan properties.

      • kJapanese

      • kMojiJoho

      • kSMSZD2003Index

      • kSMSZD2003Readings

      • kVietnameseNumeric

      • kZhuangNumeric

    • Add “IDS_Unary_Operator” property.

    • Add “ID_Compat_Math_Start” property.

    • Add “ID_Compat_Math_Continue” property.

    • Add “NFKC_Simple_Casefold” property.

    • Check if multiple “kPrimaryNumeric” values are supported (see U+5146 and U+79ED).

  • Use Unicode version supported by Python version.

    • Updated the path_map to handle different Unicode versions.

    • Updated the prop_map to handle different Unicode versions.

    • Can specify the Unicode version of a FileCache.

    • Create a FileCache for the Unicode version supported by the running Python on launch.

  • Generate denormalizations for each version.

  • Return an AttributeError rather than KeyError when an attribute doesn’t exist.

How Do I Run the Tests?

charex is using the pytest package for unit testing. It also comes with a makefile that automates testing. So, to run the tests:

  • Install poetry: pip install poetry

  • Install the development dependencies: poetry install

  • To run just the unit tests: make test

  • To run the full test suite: make pre

Common Problems

ModuleNotFoundError: No module name ‘_tkinter’ error

If you get the above error when running charex or its tests, it’s likely your Python install doesn’t have tkinter linked. How you fix it depends upon your Python install. If you are using Python 3.14 installed with homebrew on macOS, you can probably fix it with:

brew install python-tk@3.14

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

charex-0.2.4.tar.gz (61.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

charex-0.2.4-py3-none-any.whl (61.6 MB view details)

Uploaded Python 3

File details

Details for the file charex-0.2.4.tar.gz.

File metadata

  • Download URL: charex-0.2.4.tar.gz
  • Upload date:
  • Size: 61.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for charex-0.2.4.tar.gz
Algorithm Hash digest
SHA256 4f0f3708ee063250335c35420467c229c4fefc09e2aaa4e150ae737e4c557230
MD5 c8bbfca98921e10e27b7b0935e426791
BLAKE2b-256 164f009961dd88762df4e153079c07b6c3c66edb861549ae90cb21540a1b3424

See more details on using hashes here.

File details

Details for the file charex-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: charex-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 61.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for charex-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 868faa2197100c5111bf194b50095cb23ae0ff217b54536452dca2b923bf4d47
MD5 11eed342b6413f90cd2c66a306cef064
BLAKE2b-256 38ecace06c58e4b2e3aa753feeb44fe4b4c0c83b4476251aea58eebbc21ccd00

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