stringprep(n)
β¨ stringprep(n) β Preparation of Internationalized Strings β¨
okay bestie, sit down, hydrate, because we're about to make Unicode behave π (this is from the tcllib manual, btw β hi, we love her)
π NAME π
stringprep β the implementation of stringprep, no cap, that's literally it
π¦ SYNOPSIS π¦
package require Tcl 8.5 9
package require stringprep 1.0.3
::stringprep::register profile ?-mapping list? ?-normalization form?
?-prohibited list? ?-prohibitedList list? ?-prohibitedCommand command?
?-prohibitedBidi boolean?
::stringprep::stringprep profile string
::stringprep::compare profile string1 string2
π DESCRIPTION π
So this is a Tcl implementation of the Preparation of Internationalized Strings β aka "stringprep" πΈ. What does it do for you? It lets you define your own stringprep profiles and then use them to prep Unicode strings for comparison, exactly as defined in RFC-3454. It's giving "make these strings actually comparable" energy, periodt β¨
π COMMANDS π
::stringprep::register profile ?-mapping list? ?-normalization form? ?-prohibited list? ?-prohibitedList list? ?-prohibitedCommand command? ?-prohibitedBidi boolean?
Registers the stringprep profile named profile. And the options? Bestie, we got options π
-mappingβ this one specifies the stringprep mapping tables π. It takes a list of tables straight outta appendix B of RFC-3454. The usual list values are{B.1 B.2}or{B.1 B.3}, where B.1 holds characters that commonly map to nothing, B.3 is the case folding girlie, and B.2 gets used in profiles with unicode normalization form KC. The default value is{}which means... no mapping, none, zero, nada π«Ά-normalizationβ takes a string, and if it's nonempty it's used as the name of a Unicode normalization form π. Any of"D","C","KD"or"KC"may be used, though (ngl) RFC-3454 only defines two options: no normalization at all, or normalization using form KC.-prohibitedβ takes a list of RFC-3454 tables full of prohibited characters π«. The current version does allow you to prohibit either all tables fromC.3toC.9or neither of them β no in-between, that's the vibe check. An example of this list for RFC-3491 is{A.1 C.1.2 C.2.2 C.3 C.4 C.5 C.6 C.7 C.8 C.9}.-prohibitedListβ specifies a list of additional prohibited characters π. Sneaky detail: the list contains not the characters themselves but their Unicode numbers. For example, the Nodeprep specification from RFC-3920 forbids these codes:{0x22 0x26 0x27 0x2f 0x3a 0x3c 0x3e 0x40}(\"\&\'/:<>@).-prohibitedCommandβ specifies a command that gets called for every character code in the mapped and normalized string π₯. If that command returns true, the character is considered prohibited. This option is a whole lifesaver when your-prohibitedListlist is just... too large π-prohibitedBidiβ takes a boolean value, and if it's true then the bidirectional character processing rules defined in section 6 of RFC-3454 are used π§
::stringprep::stringprep profile string
Performs the stringprep operations defined in profile profile on string string β¨. The result is a prepared string, or one of these three errors, and bestie, pay attention because they WILL show up:
invalid_profileβ the profile profile is not defined πprohibited_characterβ string string contains a prohibited character π«prohibited_bidiβ string string contains a prohibited bidirectional sequence π
::stringprep::compare profile string1 string2
Compares two unicode strings prepared accordingly to stringprep profile profile π«Ά. Returns:
0if the prepared strings are equal-1if string1 is lexicographically less than string21if string1 is lexicographically greater than string2
πΈ EXAMPLES πΈ
Nameprep profile definition (see RFC-3491) β iconic, honestly:
::stringprep::register nameprep -mapping {B.1 B.2} -normalization KC -prohibited {A.1 C.1.2 C.2.2 C.3 C.4 C.5 C.6 C.7 C.8 C.9} -prohibitedBidi 1
Nodeprep and resourceprep profile definitions (see RFC-3920) β the way these two ate:
::stringprep::register nodeprep -mapping {B.1 B.2} -normalization KC -prohibited {A.1 C.1.1 C.1.2 C.2.1 C.2.2 C.3 C.4 C.5 C.6 C.7 C.8 C.9} -prohibitedList {0x22 0x26 0x27 0x2f 0x3a 0x3c 0x3e 0x40} -prohibitedBidi 1
::stringprep::register resourceprep -mapping {B.1} -normalization KC -prohibited {A.1 C.1.2 C.2.1 C.2.2 C.3 C.4 C.5 C.6 C.7 C.8 C.9} -prohibitedBidi 1
π§ REFERENCES π§
"Preparation of Internationalized Strings ('stringprep')", (http://www.ietf.org/rfc/rfc3454.txt)"Nameprep: A Stringprep Profile for Internationalized Domain Names (IDN)", (http://www.ietf.org/rfc/rfc3491.txt)"Extensible Messaging and Presence Protocol (XMPP): Core", (http://www.ietf.org/rfc/rfc3920.txt)
π AUTHORS π
Sergei Golovan β thank you for your service π«‘
π BUGS, IDEAS, FEEDBACK π
Not to be dramatic but: this document, and the package it describes, will undoubtedly contain bugs and other problems π. Please report such in the category stringprep of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. And please also report any ideas for enhancements you may have for either the package and/or the documentation β we want all of it π«Ά
When proposing code changes, please provide unified diffs, i.e the output of diff -u. Fr fr.
Also note further that attachments are strongly preferred over inlined patches β¨. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. iykyk π
π SEE ALSO π
β KEYWORDS β
stringprep, unicode
π COPYRIGHT π
Copyright (c) 2007-2009, Sergei Golovan <sgolovan@nes.ru>
okay that's the whole page, you understood all of it, I'm so proud of you bestie π₯Ήπ this was tcllib 1.0.3, the stringprep(n) page, and yeah that's the version and the date situation β go prep some strings, you're literally the main character πβ¨
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- Copyright (c) 2007-2009, Sergei Golovan <sgolovan@nes\&.ru>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms