This module allows you to convert between text and binary forms of data.
For efficiency of I/O (see the ceylon.io
module), Buffer
s are the core
representation which Codec
s output from the
encode/decode operations, but it's still easy to get more general types like
Array
s and String
s. Input to the operations can be any stream type.
Codec
s are symmetrical, as any data that is
encoded then
decoded (or vice versa) with
the same codec will be at least semantically equivalent to the starting
data, and usually exactly equal.
Codec
s come in four flavours:
ByteToByte,
ByteToCharacter,
CharacterToByte, and
CharacterToCharacter. The
middle two are similar, yet kept seperate to support differing conventions
around what encode
and decode
mean in particular codec families. To
enhance efficiency, ByteToByteCodec
s are offered as variants of some
CharacterToByteCodec
s where the Character
form is comprised of ASCII
characters only. These variants' output is the same as using the original
plus encoding the characters with the ASCII
charset.
There are three currently implemented codec families: charsets (UTF-8 for example), base encodings (like base64), and text ciphers (rot13 for example). See those packages for further documentation and examples of use.
Packages | |
ceylon.buffer | See |
ceylon.buffer.base | This package contains the “base” codecs defined by RFC 4648. |
ceylon.buffer.charset | This package contains the |
ceylon.buffer.codec | This package contains the infrastructure of the |
ceylon.buffer.readers | |
ceylon.buffer.text | This package contains implementations of
|
Dependencies | ||
ceylon.collection | 1.3.0 | |
ceylon.interop.java (jvm) | 1.3.0 | |
java.base (jvm) | 8 |
See ceylon.buffer
ceylon.buffer
Classes | |
Buffer | Source Codeshared abstract Buffer<Element> Represents a memory buffer that can be read and written to
with no allocation. The easiest way to get an idea of what
a buffer is, is that it consists in an array of a given
Typical operations on a buffer will be to fill it, which
you do with Then if you want to read the data you just put in the
buffer, you You can then start calling Once you are done reading from the buffer, you can
Buffers can be resized (grown and expanded), which will cause an underlying array reallocation and copy. |
ByteBuffer | Source Codeshared ByteBuffer Represents a buffer of |
CharacterBuffer | Source Codeshared CharacterBuffer Represents a buffer of |
Exceptions | |
BufferException | Source Codeshared BufferException |
BufferOverflowException | Source Codeshared BufferOverflowException |
BufferUnderflowException | Source Codeshared BufferUnderflowException |