Bytes Class
Bytes is an array of bytes.
Methods
this
(
Bytes
numBytes
Constructs object of type Bytes - sequence of bytes of numBytes length.
Parameters:
-
numBytes
IntegerNumber of bytes in the byte vector.
Returns:
Bytes: New instance offset Bytes
Example:
var myCars=new Array("Saab", "Volvo", "BMW");
load
(
Bytes
filename
Create new Bytes object, loads file into it and returns that object.
Parameters:
-
filename
StringName of file to open. If file does not exist function cause and error.
Returns:
Bytes: Bytes object loaded from file
save
(
filename
Save content of the byte vector into the file.
Parameters:
-
filename
StringName of file. If file exists then it will be overwritten.
toHex
() String
Create hexadecimal string from bytes array.
Returns:
String: A hexadecimal representation off the bytes.
Example:
console << "0x" << bytes.toHex() << "\n";
toString
(
String
[encoding]
Create string from bytes array. If encoding is not provided then the method returns base64 representation of the byte vector. Otherwise a string from UTF-8 encoded bytes.
Parameters:
-
[encoding]
String optionalText encoding for supported encodings see http://www.iana.org/assignments/character-sets.
Returns:
String: A string from UTF-8 encoded bytes.
Example:
// returns string from UTF-8 encoded bytes
var utf8 = bytes.toString("UTF-8");
// returns base64 representation of the bye vector.
var b64 = bytes.toString();