UVALID

UVALID returns a FIXED BIN(31) value which is zero if a string contains valid UTF data and which is the index of the first invalid element if the string does not contain valid UTF data.

Read syntax diagramSkip visual syntax diagram
>>-UVALID(x)---------------------------------------------------><

x
Expression which must have CHARACTER, WIDECHAR Start of changeor WIDEPICEnd of change type.

If x has CHARACTER type, then UVALID(x) will return 0 if the string contains valid UTF-8 data, and otherwise it will return the index of the byte where the first invalid UTF-8 data starts.

If x has WIDECHAR Start of changeor WIDEPICEnd of change type, then UVALID(x) will return 0 if the string contains valid UTF-16 data, and otherwise it will return the index of the widechar where the first invalid UTF-16 data starts.

Note that UVALID will indicate if the string contains valid UTF data (according to the rules below). It does not indicate if these bytes have actually been allocated to represent any particular character.

For UTF-8 data, the validity of a byte varies as follows according to its range:
For UTF-16 data, the validity of a widechar varies as follows according to its range:





Published: 23 December 2018