#local #ansi #charset #string #windows #strings #repository #work

local-encoding

Rust library for encoding/decoding string with local charset. It usefull for work with ANSI strings on Windows.

2 unstable releases

Uses old Rust 2015

0.2.0 Aug 9, 2016
0.1.0 Jul 12, 2016
Download history 3648/week @ 2022-06-07 3672/week @ 2022-06-14 7126/week @ 2022-06-21 6089/week @ 2022-06-28 5359/week @ 2022-07-05 4454/week @ 2022-07-12 4637/week @ 2022-07-19 4776/week @ 2022-07-26 6420/week @ 2022-08-02 6167/week @ 2022-08-09 6859/week @ 2022-08-16 3581/week @ 2022-08-23 6360/week @ 2022-08-30 4255/week @ 2022-09-06 5418/week @ 2022-09-13 5096/week @ 2022-09-20

21,686 downloads per month
Used in fewer than 15 crates

MIT license

18KB
312 lines

local-encoding

Join the chat at https://gitter.im/bozaro/local-encoding-rs Build Status Crates.io

This repository contains rust library for encoding/decoding string with local charset. It usefull for work with ANSI strings on Windows.

Unfortunately Windows widly use 8-bit character encoding instead UTF-8. This causes a lot of pain.

For example, in Russian version:

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

To convert between 8-bit and Unicode used Windows have function: MultiByteToWideChar and WideCharToMultiByte.

This library provide simple function to convert between 8-bit and Unicode characters on Windows.

UTF-8 used as 8-bit codepage for non-Windows system.

Rustdoc: https://bozaro.github.io/local-encoding-rs/local_encoding/

Usage

Put this in your Cargo.toml:

[dependencies]
local-encoding = "*"

For example:

extern crate local_encoding;

use local_encoding::{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());
}

Dependencies

~105KB