Artifact bf66d799088d45b907adf4edfbd2fda99187add6236062149f46ddb44066dcd3:
- File doc/markdown/TclCAPI/UnicodeNormalize.md — part of check-in [b84ce0eee1] at 2026-10-04 22:10:02 on branch tip-700 — file location re-organisation (part 1) (user: Torsten, size: 3798) [annotate] [blame] [check-ins using]
- File doc/markdown/UnicodeNormalize.md — part of check-in [5e80e55e41] at 2026-09-26 22:40:07 on branch tip-700 — - added a "title" metadata element to the generated yaml block to satisfy Pandoc when converting to HTML - added markdown2html.tcl as prototype/placeholder of conversion script markdown -> HTML - added some CSS to play with a good visual representation of the generated HTML, starting with the n section pages - fixed man2markdown.tcl not giving the two .TP/.IP parsing places the same treatment (user: Torsten, size: 3798) [annotate] [blame] [check-ins using]
CommandName: Tcl_UtfToNormalized title: Tcl_UtfToNormalized ManualSection: 3 Version: 9.1 TclPart: Tcl TclDescription: Tcl Library Procedures Links:
- unicode(n) Keywords:
- utf
- Unicode
- normalize Copyright:
- Copyright (c) 2025 Ashok P. Nadkarni ---
Name
Tcl_UtfToNormalized, Tcl_UtfToNormalizedDString - procedures for Unicode normalization
Synopsis
::: {.synopsis} ::: #include <tcl.h> [int]{.ret} [Tcl_UtfToNormalized]{.ccmd} [interp, src, numBytes, normForm, profile, dst, dstLen, dstWrotePtr]{.cargs} [int]{.ret} [Tcl_UtfToNormalizedDString]{.ccmd} [interp, src, numBytes, normForm, profile, dstPtr]{.cargs} :::
Arguments
::: {.arguments} :::
[*interp]{.carg .in type="Tcl_Interp"} : Interpreter to use for error reporting, or NULL if no error reporting is desired.
[*src]{.carg .in type="const char"} : An array of bytes in Tcl's internal UTF-8 based encoding.
[numBytes]{.carg .in type="Tcl_Size"} : Length of src in bytes. If the length is negative, the length includes all bytes until the first nul byte.
[*dst]{.carg .out type="char"} : Buffer in which the converted result will be stored. No more than dstLen bytes will be stored in dst.
[dstLen]{.carg .in type="Tcl_Size"} : The size of the output buffer dst in bytes.
[*dstWrotePtr]{.carg .out type="Tcl_Size"} : Filled with the number of bytes in the normalized string. This number does not include the terminating nul character. May be NULL.
[normForm]{.carg .in type="Tcl_UnicodeNormalizationForm"} : Must be one of the Tcl_UnicodeNormalizationForm members TCL_NFC, TCL_NFD, TCL_NFKC or TCL_NFKD specifying the Unicode normalization type.
[profile]{.carg .in/out type="int"} : The encoding profile as described in the Tcl_GetEncoding documentation. Must be either TCL_ENCODING_PROFILE_STRICT or TCL_ENCODING_PROFILE_REPLACE.
[*dstPtr]{.carg .out type="Tcl_DString"} : Pointer to an uninitialized or free Tcl_DString in which the converted result, which is also encoded in Tcl's internal UTF-8 encoding, will be stored. The function initializes the storage and caller must call Tcl_DStringFree on success.
:::
Description
The Tcl_UtfToNormalized and Tcl_UtfToNormalizedDString functions transform the passed string into one of the standard normalization forms defined in the Unicode standard. The normalization form is specified via the normForm argument which must have one of the values TCL_NFC, TCL_NFD, TCL_NFKC or TCL_NFKD corresponding to the Unicode normalization forms Normalization Form C (NFC), Normalization Form D (NFD), Normalization Form KC (NFKC) and Normalization Form KD (NFKD) respectively. For details on the above normalization forms, refer to Section 3.11 of the Unicode standard (https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-3/).
The Tcl_UtfToNormalized function stores the normalized result in the buffer provided by the caller through the dst argument. The result is nul terminated but the nul is not included in the count of stored bytes returned in dstWrotePtr. The function returns TCL_OK on success, TCL_CONVERT_NOSPACE if there is insufficient room in the output buffer and TCL_ERROR in case of other failures. In the latter two cases, an error message is stored in interp if it is not NULL.
The Tcl_UtfToNormalizedDString function stores the normalized result in dstPtr which must eventually be freed by caller through Tcl_DStringFree. The function returns TCL_OK on success and TCL_ERROR on failure with an error message in interp if it is not NULL.