local-encoding-ng

Crates.iolocal-encoding-ng
lib.rslocal-encoding-ng
version0.1.0
sourcesrc
created_at2022-03-11 23:59:23.719691
updated_at2022-03-11 23:59:23.719691
descriptionA rust library which simplifies the encoding and decoding from the local Windows Ansi codepage.
homepage
repositoryhttps://github.com/tyrylu/local-encoding-rs-ng
max_upload_size
id548524
size20,103
Lukáš Tyrychtr (tyrylu)

documentation

README

local-encoding-ng

Crates.io

This is local-encoding-ng, a library which wastly simplifies dealing with the unfamous Windows 8-bit encodings.

For example, in Russian version:

  • CP-1251 (ANSI codepage) is used for 8-bit files;
  • CP-866 (OEM codepage) is used for console output.

Windows have functions which help in these conversions: MultiByteToWideChar and WideCharToMultiByte.

This library provides a simple API for these functions.

Usage

Put this in your Cargo.toml:

[dependencies]
local-encoding-ng = "*"

Or, better, use cargo-edit to add it with a correct version and use it to keep the version up-to-date.

For example:

use local_encoding_ng::{Encoding, Encoder};

fn main()
{
	println!("Unicode string: {}", Encoding::ANSI.to_string(b"ANSI string").unwrap());
	println!("Unicode string: {}", Encoding::OEM.to_string(b"OEM string").unwrap());
}
Commit count: 28

cargo fmt