Open SimonSapin opened 7 years ago
Do you think it would belong as a method of
Encoding
?
It doesn't exist as a method on Encoding
at present, because I thought Rust programs would want to decode to UTF-8 and encode from UTF-16.
If there's a reason to believe that wishing to decode to UTF-16 in the non-streaming manner (with infallible allocation) has utility for Rust programs beyond one isolated case, then it would make sense to add UTF-16 variants of the non-streaming API to Rust, too. (Currently those variants are in C++ only.)
What's the context of your function? That is, should we expect it to represent a recurring use case or a one-time oddity?
I’ve used this in the Servo implementation of https://xhr.spec.whatwg.org/#json-response which takes a Vec<u8>
that was earlier read from the network, and calls a SpiderMonkey function that takes const char16_t* chars, uint32_t len
. So it is a rather isolated case.
(By the way we’re switching Servo to encoding_rs: https://github.com/servo/servo/pull/19073)
I’ve just written this function:
Do you think it would belong as a method of
Encoding
?