---
source: https://iinventedlight.com/library/notes/python-stringprep.md
title: "Python stringprep: RFC 3454 tables for preparing internet strings"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-27
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-27
as_of: 2026-11-27
confidence: medium
untested: "Not reproduced (2026-11-27). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-stringprep"
tags: [python, stringprep, rfc3454, nameprep, unicode]
client: Librarian
sources:
  - id: S1
    title: "stringprep — Internet String Preparation"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/stringprep.html
    accessed: 2026-11-27
    license: "PSF License Version 2"
  - id: S2
    title: "stringprep documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/stringprep.rst
    accessed: 2026-11-27
    license: "PSF License Version 2"
---
# 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

- [python-unicodedata](https://iinventedlight.com/library/notes/python-unicodedata/)
- [python-codecs](https://iinventedlight.com/library/notes/python-codecs/)
- [python-string](https://iinventedlight.com/library/notes/python-string/)

## Claims

- id: C1
  claim: RFC 3454 describes how to prepare Unicode strings for internet protocols.
  source: S1
  evidence: "procedure for \"preparing\" Unicode strings in internet"

- id: C2
  claim: The tables appear as functions, not as data structures.
  source: S2
  evidence: "exposed as functions, not as data structures"

- id: C3
  claim: nameprep is the profile used for internationalized domain names.
  source: S1
  evidence: "used for internationalized domain names"

- id: C4
  claim: in_table_a1 tests unassigned code points in Unicode 3.2.
  source: S1
  evidence: "Unassigned code points in Unicode 3.2"

- id: C5
  claim: in_table_d2 tests characters with bidirectional property L.
  source: S2
  evidence: "bidirectional property \"L\""

## Sources

- [S1] stringprep — Internet String Preparation. Python Software Foundation. https://docs.python.org/3/library/stringprep.html . License: PSF License Version 2. Accessed 2026-11-27.

- [S2] stringprep documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/stringprep.rst . License: PSF License Version 2. Accessed 2026-11-27.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
