textcode

docs

Intro

textcode is a library for text encoding/decoding. Supports next charsets:

Example:

```rust use textcode::iso8859_5;

const UTF8: &str = "Привет!"; const ISO8859_5: &[u8] = &[0xbf, 0xe0, 0xd8, 0xd2, 0xd5, 0xe2, 0x21];

let mut dst: Vec = Vec::new(); iso88595::encode(UTF8, &mut dst); asserteq!(dst.asslice(), ISO88595);

let mut dst = String::new(); iso88595::decode(ISO88595, &mut dst); asserteq!(UTF8, dst.asstr()); ```

Bound

Method bound - calculates bound for defined limit. For example UTF-8 string with 2 four-bytes symbols. The bound limit is 6 bytes. Method returns 4, because second symbol out of bound.

Example:

```rust use textcode::utf8;

// "🦀🦀" const UTF8_DATA: &[u8] = &[0xF0, 0x9F, 0xA6, 0x80, 0xF0, 0x9F, 0xA6, 0x80];

asserteq!(utf8::bound(UTF8DATA, 6), 4); asserteq!(utf8::bound(UTF8DATA, 1000), UTF8_DATA.len()); ```