#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

#1752 in Text processing

Download history 1/week @ 2024-11-13 5/week @ 2024-11-20 9/week @ 2024-11-27 17/week @ 2024-12-04 27/week @ 2024-12-11 4/week @ 2024-12-18 8/week @ 2025-01-15 24/week @ 2025-02-05 13/week @ 2025-02-12 4/week @ 2025-02-19 16/week @ 2025-02-26

57 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