Main Content


Unicode compatibility decomposed normalized form (NFKD)

Since R2022b



    newStr = textanalytics.unicode.nfkd(str) normalizes the string str to the Unicode compatibility decomposed normalized form (NFKD).


    collapse all

    Strings that look identical can have different underlying representations. The Unicode compatibility canonical decomposition form (NFKD) ensures that equivalent strings have a unique binary representation.

    Consider the string "jalapeño", which contains eight letters.

    str = "jalapeño";
    ans = 8

    Normalize the string using the textanalytics.unicode.nfkd function. On some systems, the output string appears to be identical to the input string.

    newStr = textanalytics.unicode.nfkd(str)
    newStr = 

    View the length of the normalized string. The normalized representation includes one extra code unit. In this case, the function splits the accented letter "ñ" into two separate code units.

    ans = 9

    Extract the seventh and eighth code units in the normalized string. On some systems, the output appears to be a single character.

    ans = 

    Check that the strings str and newStr are equal using the == operator. The operator returns 0 because the strings have different underlying representations.

    tf = str == newStr
    tf = logical

    Input Arguments

    collapse all

    Input text, specified as a string array, character vector, or cell array of character vectors.

    Example: ["An example of a short sentence."; "A second short sentence."]

    Data Types: string | char | cell

    Output Arguments

    collapse all

    Output text, returned as a string array, character vector, or cell array of character vectors. str and newStr have the same data type.


    collapse all

    Unicode Normalization Forms

    For more information about Unicode normalization forms, see Unicode Standard Annex #15 Unicode Normalization Forms.


    [1] Whistler, Ken, ed. "Unicode Standard Annex #15: Unicode Normalization Forms." Unicode Technical Reports, August 27, 2021.

    Version History

    Introduced in R2022b