62
edits
(→ByteString: use definition list for constructors) |
m (→Specification: add sub-headings) |
||
| Line 17: | Line 17: | ||
A ByteString is an immutable, fixed-width representation of a C unsigned char (byte) array. ByteString supports the String API, and indexing returns a byte substring of length 1. | A ByteString is an immutable, fixed-width representation of a C unsigned char (byte) array. ByteString supports the String API, and indexing returns a byte substring of length 1. | ||
=== Constructor === | |||
; ByteString() | ; ByteString() | ||
| Line 31: | Line 31: | ||
: Convert a string. The ByteString will contain string encoded with codec. | : Convert a string. The ByteString will contain string encoded with codec. | ||
=== Instance properties === | |||
* immutable length property | * immutable length property | ||
=== Instance methods (in prototype) === | |||
* toByteArray() -> byte for byte | * toByteArray() -> byte for byte | ||
* toByteArray(sourceCodec, targetCodec) -> transcoded | * toByteArray(sourceCodec, targetCodec) -> transcoded | ||
| Line 71: | Line 74: | ||
A ByteArray is a mutable, flexible representation of a C unsigned char (byte) array. | A ByteArray is a mutable, flexible representation of a C unsigned char (byte) array. | ||
=== Constructor === | |||
* ByteArray() | * ByteArray() | ||
| Line 84: | Line 87: | ||
All values within the length of the array are numbers stored as bytes that default to 0 if they have not been explicitly set. Assigning beyond the bounds of a ByteArray implicitly grows the array, just like an Array. Retrieving a value from an index that is out of the bounds of the Array, lower than 0 or at or beyond the length, the returned value is "undefined". Assigning an index with a value that is larger than fits in a byte will be implicitly and silently masked against 0xFF. Negative numbers will be bit extended to a byte in two's complement form and likewise masked. | All values within the length of the array are numbers stored as bytes that default to 0 if they have not been explicitly set. Assigning beyond the bounds of a ByteArray implicitly grows the array, just like an Array. Retrieving a value from an index that is out of the bounds of the Array, lower than 0 or at or beyond the length, the returned value is "undefined". Assigning an index with a value that is larger than fits in a byte will be implicitly and silently masked against 0xFF. Negative numbers will be bit extended to a byte in two's complement form and likewise masked. | ||
=== Instance properties === | |||
* mutable length property | * mutable length property | ||
** extending a byte array fills the new entries with 0. | ** extending a byte array fills the new entries with 0. | ||
=== Instance methods (in prototype) === | |||
* toArray() -> an array of the byte values | * toArray() -> an array of the byte values | ||
* toArray(codec) -> an array of the code points, decoded | * toArray(codec) -> an array of the code points, decoded | ||
edits