UTF8TOWCHAR Function

Purpose

Returns a WIDECHAR string that is UTF-16 equivalent of its UTF-8 argument

Syntax

UTF8TOWCHAR(x)

Parameters

x is an expression that represents a UTF-8 string that is converted to a character string.

Description

The UTF8TOWCHAR function returns the WIDECHAR UTF-16 equivalent of the UTF-8 argument x. If x contains invalid UTF-8 characters, the ERROR condition is raised.

Examples

     dcl u8    char(12) var;
     dcl wc    widechar(12) var;
     u8 = utf8('Hello World.');
     wc = utf8towchar(u8);
     put skip list('wc hex=', hex(wc));
     put skip list(utf8(wc));

produces the result:

        wc hex= 000C00480065006C006C006F00200057006F0072006C0064002E
        Hello World.

Restrictions

None.