Previous Topic Next topic Print topic


UTF8 Function

Purpose

Returns a character string that is the UTF-8 equivalent of its argument.

Syntax

UTF8(x)

Parameters

x is an expression that can be converted to a character string. If x is not WIDECHAR type, it is converted to character string before the conversion to its UTF-8 equivalent.

Description

The UTF8 function returns a CHARACTER string that is the UTF-8 equivalent of its argument x. The length of the returned string may be up to two times the length of x for CHARACTER and up to three times for WIDECHAR. If this length exceeds the maximum allowed for the CHARACTER type or the WIDRECHAR input string contains invalid UTF16 characters, the ERROR condition is raised.

Examples

     dcl u8    char(12) var;
     u8 = utf8('Hello World.');
     put skip list('From ASCII:  ', hex(u8));
     put skip list(utf8tochar(u8));

produces the result:

        From ASCII:     000C48656C6C6F20576F726C642E
        Hello World.

Restrictions

None.

Previous Topic Next topic Print topic