Is there a Rust library with an UTF-16 string type? (intended for writing a Javascript interpreter)
问题 For most programs, it's better to use UTF-8 internally and, when necessary, convert to other encodings. But in my case, I want to write a Javascript interpreter, and it's much simpler to store only UTF-16 strings (or arrays of u16 ), because I need to address 16-bits code units individually (this is a bad idea in general, but Javascript requires this). This means I need it to implement Index<usize> . I need to store unpaired surrogates, that is, malformed UTF-16 strings (because of this,