Description
The documentation does not specify the endianness of str::encode_utf16()
and char::encode_utf16()
: it looks from the source like they are big-endian (UTF-16BE), but I may be reading it wrong and they are little-endian (UTF-16LE) or native-endian.
This may be a deliberate design decision: if so I think it should be reconsidered, as the encoding is useless for some purposes if you don't know its endianness.
It would also be nice to indicate whether str::encode_utf16()
inserts a byte-order mark (BOM): pretty sure it does not from the source, which is fine.
It is probably too late to rename these functions or to add equivalents of opposite endianness at this point, which is too bad. It's an odd API given that the corresponding decode functions have little-endian and big-endian variants.