Converts a binary variant into a string.
BinaryToString ( expression [, flag] )
Parameters
| expression | An expression to convert into a string. |
| flag | [optional] Changes how the binary data is converted: flag = 1 (default), binary data is taken to be ANSI flag = 2, binary data is taken to be UTF16 Little Endian flag = 3, binary data is taken to be UTF16 Big Endian flag = 4, binary data is taken to be UTF8 |
Return Value
| Success: | The string representation of the binary data. |
| Failure: | An empty string. @error will bet set as follows: |
| 1 - Input string had zero length. | |
| 2 - Input string had an odd number of bytes but was supposed to be UTF16 (must contain an even number of bytes to be valid UTF16). |
Remarks
Unlike String() which returns a hexidecimal representation of binary data, this function will assume the binary data is a string value and convert it appropriately.
Related
Binary, IsBinary, String, StringToBinary, StringToASCIIArray
Example
; Binary ANSI to String
$buffer = StringToBinary("Hello - ??")
MsgBox(4096, "String() representation" , $buffer)
$buffer = BinaryToString($buffer)
MsgBox(4096, "BinaryToString() ANSI representation" , $buffer)
; Binary UTF16-LE to String
$buffer = StringToBinary("Hello - ??", 2)
MsgBox(4096, "String() representation" , $buffer)
$buffer = BinaryToString($buffer, 2)
MsgBox(4096, "BinaryToString() UTF16-LE representation" , $buffer)
; Binary UTF16-BE to String
$buffer = StringToBinary("Hello - ??", 3)
MsgBox(4096, "String() representation" , $buffer)
$buffer = BinaryToString($buffer, 3)
MsgBox(4096, "BinaryToString() UTF16-BE representation" , $buffer)
; Binary UTF8 to String
$buffer = StringToBinary("Hello - ??", 4)
MsgBox(4096, "String() representation" , $buffer)
$buffer = BinaryToString($buffer, 4)
MsgBox(4096, "BinaryToString() UTF8 representation" , $buffer)