Module Be.Decoder

A character decoder has some valid initial value init. In order to decode a character bytes has to be pushed into the decoder by put until the decoder is either complete (is_complete) or has encoutered some decoding error (has_error).

If the decoding is complete the decoded unicode character is returned by uchar. As long as the scan is not complete or if the scan has encountered some decoding error the function uchar returns rep = U+FFFD.

type t

Partially or completely scanned unicode character.

val is_complete : t -> bool

Has the unicode character been completely scanned?

val has_error : t -> bool

Has the scanning of the unicode character encountered an encoding error?

val uchar : t -> Stdlib.Uchar.t

The unicode character. In case of an error or a not yet completed scan, the unicode character rep = U+FFFD is returned.

val scalar : t -> int

The scalar value of the unicode character.

val width : t -> int

The visible width of the unicode character.

val byte_width : t -> int

Number of bytes used during decoding.

val is_newline : t -> bool

Is the decoded character a newline character?

val init : t

Initial value representing the completely scanned unicode character U+0000.

The following assertions are valid:

  • is_complete init
  • not (has_error init)
val put : char -> t -> t

put byte dec Feed the scanner with the next byte of the encoded unicode character.