UWIDTH

UWIDTH returns a FIXED BIN(31) value, which is the width of the nth UTF character in a string.

Read syntax diagramSkip visual syntax diagramUWIDTH( 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 UWIDTH(x,n) will return the width of the nth UTF-8 character, and if x has WIDECHAR type, then UWIDTH(x,n) will return the width of the nth UTF-16 character.

For example, if x equals the CHARACTER string '4b_c3_a4_66_65_72'x, then
  • UWIDTH(x,1) returns 1
  • UWIDTH(x,2) returns 2
  • UWIDTH(x,3) returns 1
  • UWIDTH(x,4) returns 1
  • UWIDTH(x,5) returns 1