| Parameter | Description |
|---|---|
| vValue | A Variant string |
| iLen (ByRef) | Returns the length, in wide characters, of the newly created buffer |
The buffer address of the converted string
Function VariantStrToUTF16 Variant vValue Integer ByRef iLen Returns Pointer
| Call: | Get VariantStrToUTF16 vValue (&iLen) to PointerVariable |
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()