ServerJS/Binary/B: Difference between revisions

→‎ByteString: use definition list for constructors
m (Added a link to the corresponding discussion and organized the headings.)
(→‎ByteString: use definition list for constructors)
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.


The ByteString constructor accepts:
The ByteString constructor:


* ByteString()
; ByteString()
* ByteString(byteString)
: Construct an empty byte string.
* ByteString(byteArray)
; ByteString(byteString)
* ByteString(array)
: Copies byteString.
* ByteString(string, codec)
; ByteString(byteArray)
: Use the contents of byteArray.
; ByteString(arrayOfNumbers)
: Use the numbers in arrayOfNumbers as the bytes.
: If any element is outside the range 0...255, an exception (''TODO'') is thrown.
; ByteString(string, codec)
: Convert a string. The ByteString will contain string encoded with codec.


ByteString instances support the following:
ByteString instances support the following:
Line 60: Line 66:


ByteString does not implement toUpperCase() or toLowerCase() since they are not meaningful without the context of a codec.
ByteString does not implement toUpperCase() or toLowerCase() since they are not meaningful without the context of a codec.


== ByteArray ==
== ByteArray ==
62

edits