ByteString
An immutable wrapper around a byte sequence providing String like functionality.
ByteString allows treating binary data as a value and passing it to other functions without worrying about data modification. The class facilitates various operations on binary data, like comparison or testing for subsequence inclusion.
ByteString is a good fit for untyped binary data that could not be represented as String, like hashes, payload of network packets, encrypted data, etc.
ByteString copies data on creation as well as on conversion back to ByteArray, thus guaranteeing that subsequent modification of source data or data returned from toByteArray won't mutate the string itself.
Properties
Functions
Returns a new read-only heap ByteBuffer wrapping this ByteString's content.
Compares a byte sequence wrapped by this byte string to a byte sequence wrapped by other in lexicographical order. Byte values are compared as unsigned integers.
Returns true
if the content of this byte string equals to the array.
Copies a subsequence starting at startIndex and ending at endIndex of a byte sequence wrapped by this byte string and writes it into destination array starting at destinationOffset offset.
Decodes content of a byte string into a string using UTF-8 encoding.
Decodes the content of a byte string to a string using given charset.
Returns true if this byte string ends with the suffix specified by the byteArray.
Returns true if this byte string ends with the suffix specified by the byteString.
Returns the index within this byte string of the first occurrence of the specified byte, starting from the specified startIndex. If the byte not found, -1
is returned.
Returns the index within this byte string of the first occurrence of the specified byteArray, starting from the specified startIndex. If the byteArray not found, -1
is returned.
Returns the index within this byte string of the first occurrence of the specified byteString, starting from the specified startIndex. If the byteString not found, -1
is returned.
Returns true
if this byte string is empty.
Returns true
if this byte string is not empty.
Returns the index within this char sequence of the last occurrence of the specified byte, starting from the specified startIndex. If the byte not found, -1
is returned.
Returns the index within this char sequence of the last occurrence of the specified byteArray, starting from the specified startIndex. If the byteArray not found, -1
is returned.
Returns the index within this char sequence of the last occurrence of the specified byteString, starting from the specified startIndex. If the byteString not found, -1
is returned.
Returns true if this byte string starts with the prefix specified by the byteArray.
Returns true if this byte string starts with the prefix specified by the byteString.
Returns a new byte string wrapping a subsequence of bytes wrapped by this byte string starting from startIndex and ending at endIndex.
Returns a copy of subsequence starting at startIndex and ending at endIndex of a byte sequence wrapped by this byte string.
Formats bytes in this byte string using the specified format.
Formats bytes in this byte string using the specified HexFormat.
Returns a new NSData instance initialized with bytes copied from this ByteString.