Parameter | Description |
---|---|
sValue | The string to convert |
eCharType | The type of string encoding, which may be OEM (CP_OEMCP), ANSI (CP_ACP) or UTF-8 (CP_UTF8) |
The buffer address of the converted string
Function Utf8FromStr String sValue Integer eCharType Returns Pointer
Call: | Get Utf8FromStr sValue eCharType to PointerVariable |
Utf8FromStr creates a UTF-8 string in a memory buffer from an OEM or ANSI DataFlex string.
The length of the returned UTF-8 string may be obtained using CStringLength(). This returns the number of bytes in the string, which may not be the same as the number of characters in the string.
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