CreateStringFromByteArray
From Spheriki
Creates a string from a ByteArray that contains each of the character values as entries.
Contents |
[edit]
Usage
string CreateStringFromByteArray(byte_array);
- byte_array Sphere ByteArray object to make the string from.
[edit]
Examples
var rf = OpenRawFile("data.txt");
var size = rf.getSize();
var str = CreateStringFromByteArray(rf.read(size));
The above code snippet will read in the contents of the text file other/data.txt into the string variable str.
[edit]
Notes
- CreateStringFromByteArray() will generate the string based on the given ByteArray. Each element of the ByteArray represents one character of the string. Characters appear in the same order in both the string and the ByteArray.
- This function is often used to retrieve string data from Sphere RawFile objects, or from network sockets.
- To convert a string to a ByteArray, use the CreateByteArrayFromString() function.
[edit]
See also
- Sphere ByteArray object
- Sphere RawFile object
- Sphere Socket object
- OpenRawFile()
- RawFile.getSize()
- RawFile.read()

