CreateStringFromByteArray

From Spheriki

Jump to: navigation, search

Creates a string from a ByteArray that contains each of the character values as entries.


Contents

Usage

string CreateStringFromByteArray(byte_array);
  • byte_array Sphere ByteArray object to make the string from.


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.


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.


See also

Personal tools