Parameter | Description |
---|---|
pWideBuf | The address of a UTF-8 string |
eCharType | The type of string encoding, which may be OEM (CP_OEMCP), ANSI (CP_ACP) or UTF-8 (CP_UTF8) |
The newly created DataFlex string
Function Utf8ToStr Pointer pWideBuf Integer eCharType Returns String
Call: | Get Utf8ToStr pWideBuf eCharType to StringVariable |
Utf8ToStr creates a OEM or ANSI DataFlex string from a UTF-16 memory buffer.
The length of the returned string may be obtained using Length().
You are responsible for eventually disposing of the newly created memory buffer.
Use Windows.pkg Use cCharTranslate.pkg Object oCharTranslate is a cCharTranslate End_Object // test Utf8FromStr and Utf8ToStr Procedure TestUTF8Str Address aUTF8Buffer Integer iVoid String sVar sVar2 Move "Test String-Ññóí" to sVar // Move OEM to UTF8 buffer Get Utf8FromStr of oCharTranslate sVar CP_OEMCP to aUTF8Buffer // Move UTF8Buffer to OEM String Get Utf8ToBuffer of oCharTranslate aUTF8Buffer CP_OEMCP to sVar2 If (sVar<>sVar2) Begin Send Info_Box "Test Failed" End Move (Free(aUTF8Buffer)) to iVoid End_Procedure Send TestUTF8StrSee Also