IS_NORMALIZED

Return true when the input string is already in the specified Unicode normalization form.

Category: stringReturns: BOOLEANDialect: PostgreSql

Syntax

IS_NORMALIZED(str [, form])

Description

## Overview Tests whether the input string is already in the specified Unicode normalization form and returns true or false. Normalisation is important when comparing or indexing text that uses combining marks: 'é' stored as a single precomposed code point (NFC) is not byte-equal to 'e' followed by a combining acute (NFD), even though both render identically. Use IS_NORMALIZED before calling NORMALIZE to avoid unnecessary rewrites when the data is already conformant. This is both a correctness check and a performance optimisation on large tables. ## Behavior - Returns NULL when either argument is NULL. - Returns true for pure ASCII strings in any normalization form. - Returns true when the string matches the canonical form byte for byte. - Returns false when any code point could be further composed, decomposed, or transformed by the specified form. - Supported forms: NFC (canonical composition), NFD (canonical decomposition), NFKC (compatibility composition), NFKD (compatibility decomposition). - Unknown form names raise an error. - Operates on Unicode code points. ## Compatibility - Matches the common SQL IS_NORMALIZED semantics. - Uses the Unicode Consortium's published normalisation tables at the engine's current Unicode version.

Parameters

NameTypeDescription
strSpecifies the input string to test for normalization.
formSpecifies the Unicode normalization form to test against. Valid values are 'NFC', 'NFD', 'NFKC', and 'NFKD'. Defaults to 'NFC'.

Examples

-- Default NFC form
SELECT IS_NORMALIZED('hello');  -- true
-- Explicit NFC
SELECT IS_NORMALIZED('café', 'NFC');  -- true
-- Same visual string in decomposed form is not NFC
SELECT IS_NORMALIZED('cafe' || CHR(769), 'NFC');  -- false (e + combining acute)
-- ASCII is always normalized in every form
SELECT IS_NORMALIZED('abc', 'NFKC');  -- true
-- NULL propagates
SELECT IS_NORMALIZED(CAST(NULL AS VARCHAR));  -- NULL
-- Audit a column for rows that need re-normalisation
SELECT customer_id, full_name
FROM retail.customers.profiles
WHERE NOT IS_NORMALIZED(full_name, 'NFC');

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →