Function Reference

StringToBinary

Converts a string into binary data.

StringToBinary ( expression [, flag] )

 

Parameters

expression An expression to convert into binary data.
flag [optional] Changes how the string is stored as binary:
  flag = 1 (default), binary data is ANSI
  flag = 2, binary data is UTF16 Little Endian
  flag = 3, binary data is UTF16 Big Endian
  flag = 4, binary data is UTF8

 

Return Value

Returns a binary variant.

 

Remarks

None.

 

Related

Binary, BinaryToString, IsBinary, String

 

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)