REVERSE
The REVERSE
function returns a character value of the same length as the argument,
whose characters are the same as those specified in the argument except
that they are in reverse order. For arguments of type national, character
positions are reversed; UTF-16 characters that are surrogate pairs
are treated as one character and UTF-16 characters that are not surrogate
pairs are treated as one character.
The function type depends on the type of the argument, as follows:
Argument type | Function type |
---|---|
Alphabetic | Alphanumeric |
Alphanumeric | Alphanumeric |
National | National |
- argument-1
- Must be class alphabetic, alphanumeric, or national and must be
at least one character in length.
argument-1 must contain valid UTF-8 or UTF-16 encoded characters:
- If argument-1 is of class alphabetic or alphanumeric, it must contain valid UTF-8 data.
- If argument-1 is of class national, it must contain valid UTF-16 data.
The returned value is a character string of the
same length as argument-1, with the characters
of argument-1 in reversed order. For example, if argument-1 contains ABC
,
the returned value is CBA
.

Example 1
If argument-1 is an alphanumeric data item that contains the UTF-8 value x'4BC3A4666572' ('Käfer'), the returned value is x'726566C3A44B' ('refäK').


Example 2
If argument-1 is a national data item that contains the UTF-16 value x'0054 00F6 D847DDF3 0062 0075 0072 D858DC6B 0073' ('Tö𡷳ber𦁫s'), the returned value is x'0073 D858DC6B 0072 0075 0062 D847DDF3 00F6 0054' ('s𦁫reb𡷳öT').


Example 3
If argument-1 is a UTF-8 encoded item and the UTF-8 argument contains composed characters, the combining characters are counted individually. For example, when encoded in UTF-8, the Unicode character ä can be x'C3A4' or x'61CC88'. With either of the UTF-8 characters in argument-1, the returned values of the REVERSE function are different. See the following table for details.
Character | Unicode encoding | UTF-8 encoding | Returned values of the REVERSE function |
---|---|---|---|
Kä | U+004B + U+00E4
(precomposed form,
latin capital letter K + latin small letter a with diaeresis) |
x'4BC3A4' (Kä) | x’C3A44B’ (äK) |
U+004B + U+0061 + U+0308
(canonical decomposition,
latin capital letter K + latin small letter a + combining diaeresis) |
x'4B61CC88' (Kä) | x’CC88614B’ (äK) |
