Add Utf16Encoder. Generalize Utf16CodeUnits for any Iterator<char>.
This allows encoding to UTF-16 something that is not in UTF-8, e.g. a `[char]` UTF-32 string. This might help with https://github.com/servo/servo/issues/4023
This commit is contained in:
@@ -114,3 +114,10 @@ fn test_rev_split_char_iterator_no_trailing() {
|
||||
split.reverse();
|
||||
assert_eq!(split, vec!["", "Märy häd ä little lämb", "Little lämb"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_utf16_code_units() {
|
||||
use core::str::Utf16Encoder;
|
||||
assert_eq!(Utf16Encoder::new(vec!['é', '\U0001F4A9'].into_iter()).collect::<Vec<u16>>(),
|
||||
vec![0xE9, 0xD83D, 0xDCA9])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user