Crate encoding_c
source ·Expand description
The C API for encoding_rs.
Mapping from Rust
Naming convention
The wrapper function for each method has a name that starts with the name of the struct lower-cased, followed by an underscore and ends with the name of the method.
For example, Encoding::for_label()
is wrapped as encoding_for_label()
.
Arguments
Functions that wrap non-static methods take the self
object as their
first argument.
Slice argument foo
is decomposed into a pointer foo
and a length
foo_len
.
Return values
Multiple return values become out-params. When an out-param is
length-related, foo_len
for a slice becomes a pointer in order to become
an in/out-param.
DecoderResult
, EncoderResult
and CoderResult
become uint32_t
.
InputEmpty
becomes INPUT_EMPTY
. OutputFull
becomes OUTPUT_FULL
.
Unmappable
becomes the scalar value of the unmappable character.
Malformed
becomes a number whose lowest 8 bits, which can have the decimal
value 0, 1, 2 or 3, indicate the number of bytes that were consumed after
the malformed sequence and whose next-lowest 8 bits, when shifted right by
8 indicate the length of the malformed byte sequence (possible decimal
values 1, 2, 3 or 4). The maximum possible sum of the two is 6.
Structs
*const Encoding
in order to be able to implement Sync
for
it.Constants
encoding_name()
.*_decode_*
and *_encode_*
functions that indicates that
the input has been exhausted.*_decode_*
and *_encode_*
functions that indicates that
the output space has been exhausted.Statics
Functions
Encoding
this Decoder
is for.Decoder
previously allocated by encoding_new_decoder()
.Encoding
this Encoder
is for.Encoder
previously allocated by encoding_new_encoder()
.true
if this is an ISO-2022-JP encoder that’s not in the
ASCII state and false
otherwise.encoding_for_label()
, except when
encoding_for_label()
would return REPLACEMENT_ENCODING
, this method
returns NULL
instead.Encoding
to a caller-supplied buffer as
ASCII and returns the number of bytes / ASCII characters written.Decoder
for the given Encoding
on the heap with BOM
sniffing enabled and returns a pointer to the newly-allocated Decoder
.Decoder
for the given Encoding
into memory provided by
the caller with BOM sniffing enabled. (In practice, the target should
likely be a pointer previously returned by encoding_new_decoder()
.)Decoder
for the given Encoding
on the heap with BOM
removal and returns a pointer to the newly-allocated Decoder
.Decoder
for the given Encoding
into memory provided by
the caller with BOM removal.Decoder
for the given Encoding
on the heap with BOM
handling disabled and returns a pointer to the newly-allocated Decoder
.Decoder
for the given Encoding
into memory provided by
the caller with BOM handling disabled.Encoder
for the given Encoding
on the heap and returns a
pointer to the newly-allocated Encoder
. (Exception, if the Encoding
is
replacement
, a new Decoder
for UTF-8 is instantiated (and that
Decoder
reports UTF_8
as its Encoding
).Encoder
for the given Encoding
into memory provided by
the caller. (In practice, the target should likely be a pointer previously
returned by encoding_new_encoder()
.)