VariantStrToUTF16 - cCharTranslate
Creates a UTF-16 string in a memory buffer from a Variant string
Type: Function
Return Data Type: Pointer
Parameters
| Parameter | Type | Description |
|---|---|---|
| vValue | Variant | A Variant string |
| ByRef iLen | Integer | Returns the length, in wide characters, of the newly created buffer |
Syntax
Function VariantStrToUTF16 Variant vValue ByRef Integer iLen Returns Pointer
Call Example
Get VariantStrToUTF16 vValue iLen to PointerVariable
Description
VariantStrToUTF16 creates a UTF-16 Unicode string in a memory buffer from a Variant String (the internal encoding of a Variant string is always Unicode).
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 | VariantStrFromUTF16 | Free()
Return Value
The buffer address of the converted string