#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

#1183 in Text processing

Download history 328/week @ 2023-12-09 61/week @ 2023-12-16 11/week @ 2024-02-17 24/week @ 2024-02-24 22/week @ 2024-03-02 32/week @ 2024-03-09 12/week @ 2024-03-16 33/week @ 2024-03-23

103 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

~510KB