Handling utf-16 strings

image
I'm using Nom to parse a binary data, at some point I have list of utf-8 or utf-16 strings controlled by a flag, each string ends with 0x00 0x00 and the first byte or two is length of the string.

How can I work with such strings with Rust?
I think there is no built-in support for utf-16.

There is no UTF-16 data structure, but you can convert &[u16] to String: https://doc.rust-lang.org/stable/std/string/struct.String.html#method.from_utf16

4 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.