Created
April 26, 2015 12:55
-
-
Save yodalee/4b5d3ee4bf7fe8145464 to your computer and use it in GitHub Desktop.
Discuss the implementation of textdecoder serialize function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn serialize(mut self, stream: &[u8]) -> &[u8] { | |
match self.encoding.name() { | |
"utf-8" | "utf-16be" | "utf-16le" if (!self.ignoreBOM && !self.BOMseen) => { | |
match stream.get(0) { | |
Some(token) => { | |
self.BOMseen = true; | |
if *token == 0xFEFF { | |
stream.slice_from(1) | |
} else { | |
stream | |
} | |
}, | |
None => stream | |
} | |
}, | |
_ => stream | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment