UPOS

UPOS returns a FIXED BIN(31) value which is the index of the nth UTF character in a string.

Read syntax diagramSkip visual syntax diagram
>>-UPOS(x,n)---------------------------------------------------><

x
Expression which must have CHARACTER or WIDECHAR type.
n
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.

If n is not positive or if n is larger than ULENGTH(x), then zero will be returned. Otherwise, if x has CHARACTER type, then UPOS(x,n) will return the position of the byte where the nth UTF-8 character starts, and if x has WIDECHAR type, then UPOS(x,n) will return the position of the widechar character where the nth UTF-16 character starts.

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





Published: 23 December 2018