← All notes

Python stringprep: RFC 3454 tables for preparing internet strings

Answer: The stringprep module exposes the tables from RFC 3454 as functions, not as data structures, for preparing Unicode strings in internet protocols.

The RFC 3454 procedure

When identifying things such as host names, comparison for equality may depend on the application domain, e.g. whether it should be case-insensitive.

Tables from the RFC are combined into profiles. Each profile must define which tables also it uses, and what other optional parts of the also stringprep procedure are part of the profile.

nameprep is the profile used for internationalized domain names.

Functions, not raw tables

The module surfaces only the RFC 3454 tables, via the Unicode character database rather than huge dictionaries.

Set tables return True when a code point is in the set. Mapping tables return the mapped value for a key.

The named table helpers

in_table_a1 checks Unassigned code points in Unicode 3.2. in_table_b1 checks Commonly mapped to nothing.

map_table_b2 applies the NFKC case-folding map. map_table_b3 applies the case-folding map that uses no normalization.

in_table_c11 tests ASCII space characters, and in_table_c12 tests Non-ASCII space characters. in_table_c11_c12 tests the union, table C.1.

in_table_c21 and in_table_c22 test ASCII and Non-ASCII control characters. in_table_c21_c22 tests their union, table C.2.

Further functions cover Private use, Non-character code points, Surrogate codes, and the other C.3 through C.9 tables.

in_table_d1 checks bidirectional property R or AL. in_table_d2 checks bidirectional property L.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, stringprep — Internet String Preparation; CPython, stringprep documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, stringprep — Internet String Preparation; CPython, stringprep documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:sgdxwjke

iinventedlight. 2026. "Python stringprep: RFC 3454 tables for preparing internet strings." iinventedlight Library, iil:note:sgdxwjke, version of 2026-11-27. https://iinventedlight.com/library/notes/python-stringprep/. License: CC-BY-4.0.

@misc{iil_note_sgdxwjke,
  author = {{iinventedlight}},
  title = {{Python stringprep: RFC 3454 tables for preparing internet strings}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-27},
  url = {https://iinventedlight.com/library/notes/python-stringprep/},
  note = {Permanent ID iil:note:sgdxwjke. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-stringprep.md.