Function Reference


Converts an array of ASCII codes to a string.

StringFromASCIIArray ( array,[start = 0 [, end = -1 [, encoding = 0]]] )


array The array of ASCII codes to convert to characters.
start [optional] The 0-based index to start processing from (Default: 0).
end [optional] The 0-based index to end processing at (Default: UBound($aArray)). Note that the character at this index is NOT included in the output.
encoding [optional] The array contains 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: a string with character representations of the ASCII codes.
Failure: an empty string and sets the @error flag to non-zero.
@error: 1 = Input is not an array.
2 = Invalid start index.


The returned string may contain embedded Chr(0) but will still be a string type. Most string functions will stop at the first Chr(0) found, however, if access to the entire contents of the string is required then the StringToBinary() function can convert it into a BinaryString preserving all the data.

If you attempt to create an array manually (As opposed to using an array returned from StringToASCIIArray()) then the codes in the array must be specified in UNICODE.




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


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.

        ; 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