Crate codepage_strings[][src]

This Rust crate builds on the excellent work of the encoding_rs, codepage, and oem-cp crates in an attempt to provide idiomatic encoding and decoding of strings coded according to Windows code pages.

Because Windows code pages are a legacy rathole, it is difficult to transcode strings using them. Sadly, there are still a lot of files out there that use these encodings. This crate was specifically created for use with RIFF, a file format that has code pages baked in for text internationalization.

No effort has been made to deal with Windows code pages beyond those supported by codepage and oem-cp. If the single-byte codepage you need is missing, I suggest taking a look at adding it to oem-cp, which seems to be the main Rust repository for unusual Windows code page tables. I believe that most of the single-byte code pages supported by iconv are dealt with here, but I haven’t checked carefully.

Other than UTF-16LE and UTF-16BE, multibyte Windows code pages are not (for now) currently supported — in particular various Asian languages. Code page 65001 (UTF-8) is supported as an identity transformation. UTF-32LE and UTF32-BE are not supported. EBCDIC code pages and UTF-7 are not supported and are low priority, because seriously?

No particular effort has been put into performance. The interface allows std::borrow::Cow to some extent, but this is limited by the minor impedance mismatches between encoding_rs and oem-cp.


Do some string conversions on Windows code page 869 (alternate Greek).

let coding = Coding::new(869)?;
    vec![214, 215],
    coding.decode(&[214, 215])?,
    coding.decode_lossy(&[214, 147]),
    coding.decode(&[214, 147]),



Coding information derived from a Windows code page.



Errors that can result from various conversions.