Package-level declarations

Utilities for getting the size, in bytes, of an individual Char, CharArray, or CharSequence when encoded as Modified UTF-8 data. For the sake of brevity, this is referred to as the mutf8Length (Modified UTF-8 length).

JVM-specific utilities for Modified UTF-8 I/O with Java's InputStream and OutputStream classes

Utilities for getting the size, in bytes, of an individual Char, CharArray, or CharSequence when encoded as Modified UTF-8 data. For the sake of brevity, this is referred to as the mutf8Length (Modified UTF-8 length).

Types

Link copied to clipboard
expect open class EOFException(message: String) : IOException

Thrown when the end of a binary sequence is reached earlier than expected while reading.

actual typealias EOFException = EOFException
actual open class EOFException(message: String) : IOException
Link copied to clipboard
expect open class IOException(message: String, cause: Throwable? = null) : Exception

Thrown when issue occurs while trying to read or write data to an external location, like a file or network socket.

actual typealias IOException = IOException
actual open class IOException(message: String, cause: Throwable?) : Exception
Link copied to clipboard
abstract class Mutf8Sink(bytesPerWrite: Int = 1024)

Something that Modified UTF-8 data can be written to.

Link copied to clipboard
abstract class Mutf8Source

Something that Modified UTF-8 data can be read from.

Link copied to clipboard
class StreamMutf8Sink(stream: OutputStream, bytesPerWrite: Int = 1024) : Mutf8Sink

A Mutf8Sink that writes its data to an OutputStream.

Link copied to clipboard

A Mutf8Source that reads its data from an InputStream.

Link copied to clipboard
expect open class UTFDataFormatException(message: String) : IOException

Thrown when malformed Modified UTF-8 data is read.

actual open class UTFDataFormatException(message: String) : IOException

Functions

Link copied to clipboard
@JvmName(name = "of")
fun CharArray.mutf8Length(startIndex: Int = 0, endIndex: Int = size): Long

The summed mutf8Length for the characters in a subsection of this array.

@JvmName(name = "of")
fun CharSequence.mutf8Length(startIndex: Int = 0, endIndex: Int = length): Long

The summed mutf8Length for the characters in a subsequence of this one.

Link copied to clipboard
@JvmName(name = "readArrayFrom")
fun InputStream.readMutf8Array(): CharArray

Creates a StreamMutf8Source around the receiver, reads the length & contents of a Modified UTF-8 string, and then returns the contents as a CharArray.

Link copied to clipboard
@JvmName(name = "readStringFrom")
fun InputStream.readMutf8String(): String

Creates a StreamMutf8Source around the receiver, reads the length & contents of a Modified UTF-8 string, and then returns the contents as a String.

Link copied to clipboard
@JvmName(name = "readToAppendableFrom")
fun InputStream.readMutf8ToAppendable(destination: Appendable)

Creates a StreamMutf8Source around the receiver, reads the length & contents of a Modified UTF-8 string, and then writes those contents to the supplied destination, such as a StringBuilder.

Link copied to clipboard
fun OutputStream.writeMutf8Array(characters: CharArray, range: IntRange = 0..characters.lastIndex, bytesPerWrite: Int = DEFAULT_BYTES_PER_WRITE)
@JvmName(name = "writeArrayTo")
fun OutputStream.writeMutf8Array(characters: CharArray, startIndex: Int = 0, endIndex: Int = characters.size, bytesPerWrite: Int = DEFAULT_BYTES_PER_WRITE)

Creates a StreamMutf8Sink around the receiver, writes the mutf8Length of the characters, and then writes the characters themselves.

Link copied to clipboard
fun OutputStream.writeMutf8Sequence(characters: CharSequence, range: IntRange = 0..characters.lastIndex, bytesPerWrite: Int = DEFAULT_BYTES_PER_WRITE)
@JvmName(name = "writeSequenceTo")
fun OutputStream.writeMutf8Sequence(characters: CharSequence, startIndex: Int = 0, endIndex: Int = characters.length, bytesPerWrite: Int = DEFAULT_BYTES_PER_WRITE)

Creates a StreamMutf8Sink around the receiver, writes the mutf8Length of the characters, and then writes the characters themselves.

Properties

Link copied to clipboard
@get:JvmName(name = "of")
val Char.mutf8Length: Int

The number of bytes used to encode the character in a Modified UTF-8 sequence.

@get:JvmName(name = "of")
val CharSequence.mutf8Length: Long

The summed mutf8Length for all the characters in the sequence.

@get:JvmName(name = "of")
val CharArray.mutf8Length: Long

The summed mutf8Length for all the characters in the array.