#codepage #ansi #simplifies #local #8-bit #conversion

local-encoding-ng

A rust library which simplifies the encoding and decoding from the local Windows Ansi codepage

1 unstable release

0.1.0 Mar 11, 2022

#1285 in Encoding

Download history 50/week @ 2024-09-12 97/week @ 2024-09-19 70/week @ 2024-09-26 40/week @ 2024-10-03 79/week @ 2024-10-10 103/week @ 2024-10-17 24/week @ 2024-10-24 39/week @ 2024-10-31 37/week @ 2024-11-07 66/week @ 2024-11-14 38/week @ 2024-11-21 102/week @ 2024-11-28 17/week @ 2024-12-05 44/week @ 2024-12-12 2/week @ 2024-12-19 13/week @ 2024-12-26

76 downloads per month

MIT license

18KB
309 lines

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());
}

Dependencies

~175KB