#charset #unicode #encoding #text-encoding

textcode

Text encoding/decoding library. Supports: UTF-8, ISO6937, ISO8859, GB2312

6 releases

0.2.2 May 2, 2022
0.2.1 Nov 3, 2020
0.1.2 Apr 24, 2020
0.1.1 Dec 23, 2019
0.1.0 Nov 18, 2019

#384 in Text processing

Download history 275/week @ 2023-12-15 257/week @ 2023-12-22 109/week @ 2023-12-29 259/week @ 2024-01-05 259/week @ 2024-01-12 258/week @ 2024-01-19 253/week @ 2024-01-26 284/week @ 2024-02-02 276/week @ 2024-02-09 428/week @ 2024-02-16 410/week @ 2024-02-23 311/week @ 2024-03-01 117/week @ 2024-03-08 307/week @ 2024-03-15 566/week @ 2024-03-22 704/week @ 2024-03-29

1,715 downloads per month
Used in 5 crates (3 directly)

MIT license

445KB
7.5K SLoC

textcode

docs

Intro

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

  • UTF-8
  • iso-6937 - Latin superset of ISO/IEC 6937 with Euro and letters with diacritics
  • iso-8859-1 - Western European
  • iso-8859-2 - Central European
  • iso-8859-3 - South European
  • iso-8859-4 - North European
  • iso-8859-5 - Cyrillic
  • iso-8859-6 - Arabic
  • iso-8859-7 - Greek
  • iso-8859-8 - Hebrew
  • iso-8859-9 - Turkish
  • iso-8859-10 - Nordic
  • iso-8859-11 - Thai
  • iso-8859-13 - Baltic Rim
  • iso-8859-14 - Celtic
  • iso-8859-15 - Western European
  • iso-8859-16 - South-Eastern European
  • gb2312 - Simplified Chinese

Example:

use textcode::iso8859_5;

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

let mut dst: Vec<u8> = Vec::new();
iso8859_5::encode(UTF8, &mut dst);
assert_eq!(dst.as_slice(), ISO8859_5);

let mut dst = String::new();
iso8859_5::decode(ISO8859_5, &mut dst);
assert_eq!(UTF8, dst.as_str());

No runtime deps