Registry / serialization / rtfunicode

rtfunicode

JSON →
library2.3pypypi✓ verified 87d ago

rtfunicode is a Python library (version 2.3) that provides an encoder for Unicode to RTF 1.5 command sequences. It allows for generating valid RTF output that includes international characters by registering a new `rtfunicode` codec, which can then be used directly with `str.encode()`. The library is actively maintained, with a focus on modern Python versions.

pip install rtfunicode
INSTALL
IMPORT
SIG · RTFUNICODE
R
rtfunicode
serializationpythonv2.3
Install
1.8s avg
Import
53ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.054s · 17.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.8s · import 0.052s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rtfunicode
import rtfunicode
Importing the rtfunicode module registers the 'rtfunicode' codec, making it available for string encoding.

This quickstart demonstrates how to import `rtfunicode` to register its codec, and then use the `encode('rtfunicode')` method on a standard Python string to convert Unicode characters into their RTF 1.5 command sequences.

import rtfunicode # Encode a Unicode string to RTF using the 'rtfunicode' codec unicode_string = 'Hello, RTF and unicode mix just fine! \u263A' rtf_output = unicode_string.encode('rtfunicode') print(f"Original Unicode: {unicode_string}") print(f"Encoded RTF: {rtf_output!r}") # The output includes the \uN? sequence for Unicode characters # For example, \u263A (smiling face) becomes \u9786? (N=9786 in signed 16-bit int) assert rtf_output == b'Hello, RTF and unicode mix just fine! \\u9786?'
Debug
Known issues
breakingrtfunicode version 2.3 dropped support for Python 3.9. Users on Python 3.9 must use `rtfunicode==2.2` or upgrade their Python environment.
fix
Upgrade Python to 3.10+ or install `pip install rtfunicode==2.2` for Python 3.9.
affects: >=2.3
breakingrtfunicode version 2.1 and later require Python 3.10 or newer. Earlier versions (pre-2.1) supported Python 3.3-3.9. Attempting to install or run v2.1+ on Python versions older than 3.10 will fail.
fix
Ensure your Python environment is 3.10 or newer. If legacy Python is required, use `rtfunicode<2.1`.
affects: >=2.1
gotchaIn version 2.1, rtfunicode was converted from a single module to a package. While the primary `import rtfunicode` remains functional, any tools or custom setups relying on `rtfunicode.py` as a direct file or internal module paths might require adjustments.
fix
Verify that custom tooling or internal module references are compatible with the package structure. The main usage (`import rtfunicode`) is unaffected.
affects: >=2.1
gotchaThe RTF standard uses `\uN?` where `N` is a signed 16-bit integer and `?` is a placeholder for older RTF readers. rtfunicode consistently sets this placeholder to `'?'`. If strict compliance with specific RTF readers requires a different fallback character (e.g., `\uN\'` plus a hex value), post-processing might be needed.
fix
Be aware of the fixed placeholder. For specific fallback character requirements, inspect the RTF output and implement post-processing if necessary.
affects: All versions
Errors
Common errors & fixes
LookupError: unknown encoding: rtfunicode
The 'rtfunicode' codec is not registered. This occurs when the `rtfunicode` module has not been imported.
fix
Add `import rtfunicode` at the beginning of your script. Importing the module registers the codec.
ERROR: Package 'rtfunicode' requires Python '>=3.10' but the running Python is 3.9.x
Attempting to install `rtfunicode` version 2.1 or newer on a Python environment older than 3.10.
fix
Upgrade your Python environment to 3.10 or newer. Alternatively, install a compatible older version like `pip install rtfunicode==2.2` for Python 3.9.
SyntaxError: invalid syntax (when running code from rtfunicode)
rtfunicode versions 2.1+ utilize modern Python syntax (e.g., type annotations) compatible with Python 3.10+. Running these versions on older Python interpreters will result in syntax errors.
fix
Ensure your Python environment is 3.10 or newer when using rtfunicode versions 2.1+. Upgrade Python if necessary.
Upgrade
Version history
2.3latest on PyPI · released Jan 17, 2026
Audit
Dependencies
pythonrequiredRequired for execution, version >=3.10.
Agent activity
4 hits · last 30 days
node
4
Resources
rtfunicode — pip install rtfunicode · libregistry