stringprep(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– stringprep β€” the manual, but make it slay πŸ’–

okay bestie, gather round, because this one is the glow-up page for stringprep(3tcl) β€” yes it lives in section 3tcl of the Tcl manual, and no I will not be normal about it πŸŽ€


✨ NAME ✨

stringprep β€” the Implementation of stringprep, periodt πŸ’…


🌸 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", the girlies know). it lets you define stringprep profiles and then use them to prepare Unicode strings for comparison, exactly as laid out in RFC-3454. it's giving ✨linguistic bestie energy✨, no cap.


πŸ‘‘ COMMANDS πŸ‘‘

🌈 ::stringprep::register profile ?-mapping list? ?-normalization form? ?-prohibited list? ?-prohibitedList list? ?-prohibitedCommand command? ?-prohibitedBidi boolean?

this registers a stringprep profile named profile, and the options are literally all of these:

  • -mapping β€” says which stringprep mapping tables we're using. it takes a list of tables from appendix B of RFC-3454. the usual values you'll see 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 one, and B.2 gets used in profiles with unicode normalization form KC. the default value is {}, which means no mapping at all. not me giving you the full tea πŸ“
  • -normalization β€” takes a string, and if it's nonempty then it's used as the name of a Unicode normalization form. you can use any of "D", "C", "KD" or "KC", though ngl RFC-3454 only defines two options: no normalization, or normalization using form KC. iconic of it honestly.
  • -prohibited β€” takes a list of RFC-3454 tables of prohibited characters. the current version lets you prohibit either all the tables from C.3 to C.9 or neither of them β€” no in-between, bestie, it's all or nothing πŸ™ˆ. 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. plot twist: the list does not contain the characters themselves, it contains their Unicode numbers. for example, the Nodeprep specification from RFC-3920 forbids these codes: {0x22 0x26 0x27 0x2f 0x3a 0x3c 0x3e 0x40} β€” that's (" & ' / : < > @) if you were wondering. lowkey a cursed little lineup πŸ’€
  • -prohibitedCommand β€” specifies a command that gets called for every character code in the mapped and normalized string. if the command returns true, then that character is considered prohibited. this one is your bestie when a -prohibitedList list would just be way, way too large. work smarter not harder πŸ’…
  • -prohibitedBidi β€” takes a boolean value, and if it's true then the bidirectional character processing rules defined in section 6 of RFC-3454 get used. bidi rules stay winning 🫢

🌟 ::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 you will respect them:

  • invalid_profile β€” 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. it returns 0 if the prepared strings are equal, -1 if string1 is lexicographically less than string2, or 1 if string1 is lexicographically greater than string2. a whole little ranking system, main character energy fr fr πŸ‘‘


πŸŽ€ EXAMPLES πŸŽ€

Nameprep profile definition β€” see RFC-3491:

::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:

::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 πŸ’œ

  1. "Preparation of Internationalized Strings ('stringprep')", (http://www.ietf.org/rfc/rfc3454.txt)
  2. "Nameprep: A Stringprep Profile for Internationalized Domain Names (IDN)", (http://www.ietf.org/rfc/rfc3491.txt)
  3. "Extensible Messaging and Presence Protocol (XMPP): Core", (http://www.ietf.org/rfc/rfc3920.txt)

🌸 AUTHORS 🌸

Sergei Golovan πŸ’–


πŸ¦‹ BUGS, IDEAS, FEEDBACK πŸ¦‹

okay so, real talk: this document, and the package it describes, will undoubtedly contain bugs and other problems. not a vibe, but it's the truth 😭. please report them in the category stringprep of the Tcllib Trackers at [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 the ideas, we want all of them 🫢

when proposing code changes, please provide unified diffs, i.e. the output of diff -u. yes, the actual diff format, bestie, it's the moment.

also note: attachments are strongly preferred over inlined patches. you make an attachment 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 🌈

unicode(3tcl)


⭐ KEYWORDS ⭐

stringprep, unicode


Copyright (c) 2007-2009, Sergei Golovan <sgolovan@nes.ru>


and that's the whole page, bestie β€” brought to you by tcllib, version 1.0.3, and yes that footer date/vibe is the stringprep(3tcl) era. slay, read it, register those profiles, and go prepare some Unicode πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from