Proposals:
- Rename
str::utf16_units
andUtf16Units
toencode_utf16
andUtf16Encoder
- Stabilize them
Motivation
- While it’s the technically correct term, I suspect many users don’t know or care what exactly a code unit is.
- UTF-16 handling is simple and stable enough that it belongs in
std
IMO. - People are asking for it
- UTF-16 decoding is already stable, through
String::from_utf16
.
Bonus proposals
Only slightly related, but while we’re at it: change char::encode_utf8
and char::encode_utf16
to return iterators, and stabilize them.
There is precedent of returning “short” iterators in e.g. char::lowercase
. This also means there is no need to expose a generalized Utf16Encoder
that takes any char
iterator as input, one can use Iterator::flat_map
with char::encode_utf16
.
CC @aturon, @alexcrichton