UTF8

UTF8 function converts a latin1 or binary string into the UTF-8 equivalent byte sequence.

COMMAND SYNTAX

    UTF8(expression)

SYNTAX ELEMENTS

The expression is expected to be a binary/latin1 code page string, which is converted into a UTF-8 encoded byte sequence.

EXAMPLE

       lat_line = CHAR(198) : CHAR(189) : CHAR(191)
       utf_line = UTF8(lat_line)
       FOR i = 1 TO 6 STEP 2
          CRT DTX( SEQ(utf_line[i,1]) ), DTX( SEQ(utf_line[i+1,1]) )
       NEXT i

The output of this program is:

     C3 86 (latin capital letter ae)
     C2 BD (vulgar fraction one half)
     C2 BF (inverted question mark)

TAFJ note: output is:

     C6 BD
     BF 0
     0 0

NOTE

To run this example the following environment variables are to be set:

     JBASE_I18N=1
     JBASE_CODEPAGE=utf8

Last update: Wed, 31 Aug 2022 10:15