Example from documentation
https://doc.rust-lang.org/book/ch08-02-strings.html
fn main() {
for b in "Зд".bytes() {
println!("{b}");
}
}
return the four bytes that make up this string
208
151
208
180
How to get back?
like this
fn main() {
let u: Vec<u8> = vec![208, 151, 208, 180];
println!("u = {:?}", std::str::from_utf8 (&u[..]).unwrap()); // ? not work
}
But if the string is without Cyrillic (for example "my text"), it works:
fn main() {
let u: Vec<u8> = vec![109, 121, 32, 116, 101, 120, 116];
println!("u = {:?}", std::str::from_utf8 (&u[..]).unwrap()); // my text
}
how to fix for Cyrillic and different data, thanks.