Function Reference


StringToASCIIArray

Converts a string to an array containing the ASCII code of each character.

StringToASCIIArray ( "string",[start = 0 [, end [, encoding = 0]]] )

Parameters

"string" The string to convert to an array of ASCII codes.
start [optional] The 0-based position to start processing from (Default: 0).
end [optional] The 0-based position to end processing at (Default: StringLen("string")).
encoding [optional] The returned array will contain values in the specified character set:
    $SE_UTF16 (0) = UTF-16 (Default)
    $SE_ANSI (1) = ANSI
    $SE_UTF8 (2) = UTF-8

Constants are defined in StringConstants.au3.

Return Value

Success: an array where each element is the UNICODE code of the character at the corresponding position.
Failure: an empty string.

Remarks

The string may contain embedded Chr(0). These will appear in the returned array as well as any data past them. Processing only stops when the end of the string is reached or the user specified end.

In order to convert binary data to an array using this function it must first be converted to a string with the BinaryToString() function.

Related

BinaryToString, StringFromASCIIArray

Example

#include <MsgBoxConstants.au3>
#include <Array.au3> ; Required for _ArrayDisplay() only.

Example()

Func Example()
    ; Convert the string to an ASCII array.
    Local $aArray = StringToASCIIArray("This is a sentence with whitespace.")

    ; Display the array to see that it contains the ASCII values for each character in the string.
    _ArrayDisplay($aArray)

    ; Convert the array into a string.
    Local $sString = StringFromASCIIArray($aArray)

    ; Display the string to see that it matches the original string initially converted to an array.
    MsgBox($MB_SYSTEMMODAL, "", $sString)
EndFunc   ;==>Example