Common Lisp Package: CL-POSTGRES-TRIVIAL-UTF-8

README:

FUNCTION

Public

READ-UTF-8-STRING (INPUT &KEY NULL-TERMINATED STOP-AT-EOF (CHAR-LENGTH -1) (BYTE-LENGTH -1))

Read utf-8 encoded data from a byte stream and construct a string with the characters found. When null-terminated is given it will stop reading at a null character, stop-at-eof tells it to stop at the end of file without raising an error, and the char-length and byte-length parameters can be used to specify the max amount of characters or bytes to read.

STRING-TO-UTF-8-BYTES (STRING &KEY NULL-TERMINATE)

Convert a string into an array of unsigned bytes containing its utf-8 representation.

UTF-8-BYTE-LENGTH (STRING)

Calculate the amount of bytes needed to encode a string.

UTF-8-BYTES-TO-STRING (BYTES-IN &KEY (START 0) (END (LENGTH BYTES-IN)))

Convert a byte array containing utf-8 encoded characters into the string it encodes.

UTF-8-GROUP-SIZE (BYTE)

Determine the amount of bytes that are part of the character starting with a given byte.

WRITE-UTF-8-BYTES (STRING OUTPUT &KEY NULL-TERMINATE)

Write a string to a byte-stream, encoding it as utf-8.

Private

GET-UTF-8-CHARACTER (BYTES GROUP-SIZE &OPTIONAL (START 0))

Given an array of bytes and the amount of bytes to use, extract the character starting at the given start position.

UTF-8-STRING-LENGTH (BYTES &KEY (START 0) (END (LENGTH BYTES)))

Calculate the length of the string encoded by the given bytes.

MACRO

Private

AS-UTF-8-BYTES (CHAR WRITER)

Given a character, calls the writer function for every byte in the encoded form of that character.

VARIABLE

Private

Undocumented

*OPTIMIZE*

CONDITION

Public

Undocumented

UTF-8-DECODING-ERROR