local-encoding-ng 0.1.0

A rust library which simplifies the encoding and decoding from the local Windows Ansi codepage.
Documentation
  • Coverage
  • 100%
    9 out of 9 items documented0 out of 5 items with examples
  • Size
  • Source code size: 20.1 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 353.26 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • tyrylu/local-encoding-rs-ng
    0 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • tyrylu

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