Skip to main content

MSX Character Set Converter

Test

A Python library for converting between Unicode and MSX character sets. It registers standard codecs so you can use the familiar str.encode / bytes.decode API, filesystem I/O, and incremental/stream interfaces.

Features

  • MSX character sets:
    • Japanese (msx-jp) — hiragana/katakana, dakuten/handakuten, graphic characters
    • International (msx-intl)
    • Brazilian (msx-br)
  • Python 3.9+
  • errors handling: strict, replace, ignore
  • Full codecs integration: incremental encoder/decoder, stream reader/writer
  • Underscore aliases: msx_jp, msx_intl, msx_br

Importing the package registers the codecs:

import msx_charset  # required once per process

"こんにちは".encode("msx-jp")

Installation

pip install msx-charset

Usage

Japanese (msx-jp)

import msx_charset

text = "こんにちは"
encoded = text.encode("msx-jp")
decoded = encoded.decode("msx-jp")

Voiced/semi-voiced kana and two-byte graphic characters (e.g. 月) are supported.

International (msx-intl)

import msx_charset

text = "áéíóú"
encoded = text.encode("msx-intl")
decoded = encoded.decode("msx-intl")

Brazilian (msx-br)

import msx_charset

text = "Olá, mundo!"
encoded = text.encode("msx-br")
decoded = encoded.decode("msx-br")

Error handling

By default, errors="strict" is used:

Situation strict replace ignore
Unmappable character on encode UnicodeEncodeError 0x3F (?) skip
Invalid/unknown byte on decode UnicodeDecodeError ? skip
Incomplete graphic sequence (0x01 …) UnicodeDecodeError ? skip
# Legacy behaviour (silent ?) — use replace explicitly
text.encode("msx-jp", errors="replace")
data.decode("msx-jp", errors="replace")

Note (0.2.0): Versions before 0.2.0 behaved like replace even when strict was requested. From 0.2.0 onward, strict raises as documented above.

Files and streams

import msx_charset

with open("message.txt", "w", encoding="msx-jp") as f:
    f.write("Hello、こんにちは")

with open("message.txt", "r", encoding="msx-jp") as f:
    text = f.read()

Japanese encoding notes

  • Full-width space (U+3000) is defined at both 0x90 and 0xA0 on decode; both decode to  . Encode uses the canonical byte 0xA0. Text round-trips are stable; raw byte-for-byte round-trip is not guaranteed when the source used 0x90 for space.

Development

Setup

python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -e .

pip install -e . is recommended so package metadata (including version from Git tags via setuptools-scm) is available.

You can also add the repo root to PYTHONPATH to run tests without installing; codecs still work, but msx_charset.__version__ is 0.0.0+unknown until the package is installed.

Running tests

python -m unittest discover -s tests

Contributing

Contributions are welcome. Please open a Pull Request.

License

MIT License

Metadata

Release files for msx-charset 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for msx-charset 0.2.0
File Size Uploaded Provenance Actions
msx_charset-0.2.0.tar.gz 11.8 kB Without provenance Details for msx_charset-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for msx-charset 0.2.0
File Interpreter ABI Platform Actions
msx_charset-0.2.0-py3-none-any.whl Python 3 none any Details for msx_charset-0.2.0-py3-none-any.whl

Total release size: 23.1 kB

Release files / msx_charset-0.2.0.tar.gz

Download URL msx_charset-0.2.0.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
94ed805ef97b6ce4ef7eff2fdd96d9616c5e0fe81b624ccf20c8e368a3c8fcf3
BLAKE2b-256 checksum
How to use checksums
0ca7e376e125882f85c25f1d35460e54ae357d58e59b49ee93957f196198a9f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / msx_charset-0.2.0-py3-none-any.whl

Download URL msx_charset-0.2.0-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3687d938b61ea37ffc6071d97d1caafccde1c373c2f1a75e5e34a6de44689bf4
BLAKE2b-256 checksum
How to use checksums
33ebfa9696e5ec00ddb500572fed65e2801a5bca1d0859920fc47fda6b94550b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for msx-charset 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page