utf16

Function utf16 

Source
pub fn utf16<'a, I>() -> impl Parser<I, Output = char>
where I: Positioned<Ok = u16> + ?Sized + 'a,
Expand description

A UTF-16 encoded u16 decoder.

ยงExamples

use somen::prelude::*;

let mut parser = utf16();
let mut stream = stream::from_slice(&[
    0xD834, 0xDD1E, 0x004d, 0x0075, 0x0073, 0x0069, 0x0063, 0xD834,
]);

assert_eq!(parser.parse(&mut stream).await, Ok('๐„ž'));
assert_eq!(parser.parse(&mut stream).await, Ok('M'));
assert_eq!(parser.parse(&mut stream).await, Ok('u'));
assert_eq!(parser.parse(&mut stream).await, Ok('s'));
assert_eq!(parser.parse(&mut stream).await, Ok('i'));
assert_eq!(parser.parse(&mut stream).await, Ok('c'));
assert!(parser.parse(&mut stream).await.is_err());