Utf8ToAnsi

See Also: AnsiToUtf8, String Functions

Purpose

Converts a string to the ANSI character format.

Return Type

String

Syntax

Use CharTranslate.pkg

 

(Utf8ToAnsi( {stringValue} ))

Where:

What It Does

DataFlex strings are by default encoded as UTF-8. When working with external APIs or when exporting data, it is sometimes necessary to convert strings to ANSI.

Note that this should be used with caution, as most string functions will not function properly on ANSI strings.

Also, the debugger will not be able to display ANSI strings correctly, as it expects UTF-8. Converting from UTF-8 to ANSI is a lossy conversion, which means that not all characters can be represented in the limited ANSI set and will be replaced by the ? character.

Examples

Procedure Test

    String sValue sAnsiString

 

    // move a value to string sValue

 

    Move (Utf8ToAnsi(sValue)) to sAnsiString

End_Procedure