#ffi #byte-string #utf-8 #wide

string-box

Create Rust string from UTF-8 string, byte string or wide string

4 stable releases

1.1.1 Jan 13, 2023
1.1.0 Oct 25, 2022
1.0.1 Oct 21, 2022

#1646 in Text processing

Download history 15/week @ 2024-08-26 6/week @ 2024-09-02 8/week @ 2024-09-09 10/week @ 2024-09-16 14/week @ 2024-09-23 26/week @ 2024-09-30 4/week @ 2024-10-07 7/week @ 2024-10-21 7/week @ 2024-10-28 1/week @ 2024-11-04 3/week @ 2024-11-18 7/week @ 2024-11-25 16/week @ 2024-12-02 29/week @ 2024-12-09

55 downloads per month
Used in 2 crates

MIT license

10KB
183 lines

StringBox

Crates.io MIT licensed

Allows developers to create Rust String from byte-string, utf-8 encoded C-string or wide-string.

Examples

From a not null-terminated byte-string:

let byte_string = vec![104u8, 101, 108, 108, 111];
let string = StringBox::from_byte_string(byte_string);
assert_eq!(string.to_string(), String::from("hello"));

From a null-terminated utf-8 string:

let utf8_string = vec![104u8, 101, 108, 108, 111, 0];
let string = StringBox::from_utf8_string(utf8_string.as_slice());
assert_eq!(string.to_string(), String::from("hello"));

Dependencies

~520KB