From 182467c1d393dee2081ff80f1c049cb145f23123 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 20 Jun 2022 18:53:38 +0200 Subject: Add support for BOM --- src/tokenizer.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/tokenizer.rs') diff --git a/src/tokenizer.rs b/src/tokenizer.rs index d31c8c5..c0a7105 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -680,10 +680,20 @@ fn attempt_impl( // To do: handle BOM at start? pub fn as_codes(value: &str) -> Vec { let mut codes: Vec = vec![]; + let mut at_start = true; let mut at_carriage_return = false; let mut column = 1; for char in value.chars() { + if at_start { + if char == '\u{feff}' { + // Ignore. + continue; + } + + at_start = false; + } + // Send a CRLF. if at_carriage_return && '\n' == char { at_carriage_return = false; -- cgit