How to Convert a String of Integers into an Array of Byte.
By: Justin Swett
Question: How can I create an array of byte values that correspond to an integer string of arbitrary length?
Suggestion: The best solution is to dynamically create an array of byte
that has length equal to that of the string. Once you have your array you
can fill the array with the values from the string, however there is some
offset since the ascii representation of the character '1' isn't equivalent to 1.
Below is a sample of how one might return an array of byte:
//dynamic array type for Array of Byte
TByteArr = array of byte;
function ArrOfByte(AStr: String): TByteArr;
SetLength( Result, Length(AStr));
for i := 0 to Length(AStr) - 1 do
Result[i] := ord(AStr[i + 1]) - 48;
Published on: 8/5/2002 12:00:00 AM
Server Response from: ETNASC03