#Windows #ANSI #Unicode #Multi-byte

windy

A Windows strings library that supports AString (ANSI string) and WString (Unicode string)

5 releases

new 0.1.4 Jan 12, 2021
0.1.3 Jan 11, 2021
0.1.2 Jan 10, 2021
0.1.1 Dec 16, 2020
0.1.0 Dec 14, 2020

#137 in Text processing

30 downloads per month
Used in 2 crates (via windy-macros)

MIT/Apache

41KB
1K SLoC

Windy

crates.io docs.rs

A Windows strings library that supports AString (ANSI string) and WString (Unicode string).

Features

  • ANSI string(AString)
  • Unicode string(WString)
  • Interconversion between AString, WString and String.
  • no_std support
  • Macros support

Installation

Add the following lines to your Cargo.toml:

[dependencies]
windy = "0.1.3"

Example

An example of parsing the outputs of cmd.exe.

use windy::AString;
use std::process::Command;

fn main() {
    let o = Command::new("cmd")
        .args(&["/c", "ThisCommandDoesNotExist"])
        .output().unwrap();
    let (stdout, stderr) = unsafe {
        (
            AString::new_unchecked(o.stdout),
            AString::new_unchecked(o.stderr)
        )
    };
    println!("stdout: {:?}", stdout);
    println!("stderr: {:?}", stderr);
}

no_std support

If you don't want to use std, use --no-default-features.

AString and WString are not available when no_std.

Macros support

windy-macros to convert a UTF-8 string to WString or AString at compile time.

If you want to use macros, turn on the macros feature.

Example

use windy::WStr;
use windy::macros::wstr;

fn main() {
    let s: &WStr = wstr!("test");
}

License

This software is released under the MIT or Apache-2.0 License, see LICENSE-MIT or LICENSE-APACHE.

Dependencies

~125KB