stringprep(n)

πŸ“¦
version 2.0 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

✨ 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 from C.3 to C.9 or 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 -prohibitedList list 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:

  • 0 if the prepared strings are equal
  • -1 if string1 is lexicographically less than string2
  • 1 if 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 🧚

  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 β€” 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 🌈

unicode(n)


⭐ KEYWORDS ⭐

stringprep, unicode


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