VariantStrFromUTF16 - cCharTranslate
Creates a Variant String from a UTF-16 Unicode string in a memory buffer
Type: Function
Return Data Type: Variant
Parameters
| Parameter | Type | Description |
|---|---|---|
| pSource | Pointer | The address of a null terminated string |
Syntax
Function VariantStrFromUTF16 Pointer pSource Returns Variant
Call Example
Get VariantStrFromUTF16 pSource to VariantVariable
Description
VariantStrFromUTF16 creates a Variant String from a UTF-16 Unicode string in a memory buffer.
You are responsible for eventually disposing of the newly created memory buffer.
See discussion in the cCharTranslate class overview about the advantages and disadvantage of using the Variant String type.
Use Windows.pkg
Use cCharTranslate.pkg
Object oCharTranslate is a cCharTranslate
End_Object
Procedure TestVariantBuffer2
Address aUTF16Buffer
Integer iVoid iLen
Variant vVar vVar2
Move "Test String-Ññóí" to vVar
// Move Variant (utf-16) to utf-16 buffer
Get VariantStrToUTF16 of oCharTranslate vVar (&iLen) to aUTF16Buffer
// Move UTF-16 buffer to variant (utf-16)
Get VariantStrFromUTF16 of oCharTranslate aUTF16Buffer to vVar2
If (vVar<>vVar2) Begin
Send Info_Box "Test Failed"
End
Move (Free(aUTF16Buffer)) to iVoid
End_Procedure
Send TestVariantBuffer2
See Also
VariantStrFromBuffer | VariantStrToBuffer | VariantStrFromStr | VariantStrToStr | VariantStrToUTF16 | Free()
Return Value
A Variant copy of the string is created and returned it as a Variant string