USUBSTR

USUBSTR returns a substring of a UTF string.

Read syntax diagramSkip visual syntax diagram
>>-USUBSTR(x,i,j)----------------------------------------------><

x
Expression which must have CHARACTER or WIDECHAR type.
i
Expression which must have computational type and which will be converted to FIXED BIN(31) if necessary.
j
Expression which must have computational type and which will be converted to FIXED BIN(31) if necessary.

If x has CHARACTER type, then the string must contain valid UTF-8 data. If not, the program is in error.

If x has WIDECHAR type, then the string must contain valid UTF-16 data. If not, the program is in error.

The ERROR condition (and not the STRINGRANGE condition) will also be raised if

If x has CHARACTER type, then USUBSTR(x,i,j) will return a CHARACTER string containing the j UTF-8 characters in x starting with the ith UTF-8 character.

If x has WIDECHAR type, then USUBSTR(x,i,j) will return a WIDECHAR string containing the j UTF-16 characters in x starting with the ith UTF-16 character.

In general, USUBSTR(x,i,j) will not equal SUBSTR(x,i,j).

For example, if x equals the CHARACTER string '4b_c3_a4_66_65_72'x, then