Parameter | Description |
---|---|
pMultiCharBuffer | The address of a null terminated string |
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 Utf8FromBuffer Pointer pMultiCharBuffer Integer eCharType Returns Pointer
Call: | Get Utf8FromBuffer pMultiCharBuffer eCharType to PointerVariable |
Utf8FromBuffer creates a UTF-8 string in a memory buffer from an OEM or ANSI memory buffer.
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 Utf8FromBuffer and Utf8ToBuffer Procedure TestUTF8Buffer Address aVar aUTF8Buffer aVar2 Integer iVoid String sVar sVar2 Move "Test String-Ññóí" to sVar Move (AddressOf(sVar)) to aVar // Move OEM to UTF8 buffer Get Utf8FromBuffer of oCharTranslate aVar CP_OEMCP to aUTF8Buffer // Note length of UTF-8 buffer is CStringLength(aUTF8Buffer) // Move UTF8 Buffer to OEM String Get Utf8ToBuffer of oCharTranslate aUTF8Buffer CP_OEMCP to aVar2 // Note length of OEM buffer is CStringLength(aVar2) Move aVar2 to sVar2 If (sVar<>sVar2) Begin Send Info_Box "Test Failed" End Move (Free(aUTF8Buffer)) to iVoid Move (Free(aVar2)) to iVoid End_Procedure Send TestUTF8BufferSee Also