USUBSTR
USUBSTR returns a substring of a UTF string.
- 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
- i is less than 1, or
- j is less than zero, or
- i + j - 1 is larger than ULENGTH(x)
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 - USUBSTR(x,1,2) returns
'4b_c3_a4'x
- USUBSTR(x,2,1) returns
'c3_a4'x
- USUBSTR(x,2,2) returns
'c3_a4_66'x
- USUBSTR(x,3,2) returns
'66_65'x