git.iko.soy/typeable/pandoc
on master help sign in
Modified fromUTF8 to strip out the BOM (byte order marker)
65a5db2fiddlosopher
src/Text/Pandoc/UTF8.hs+1
@@ -16,6 +16,7 @@ module Text.Pandoc.UTF8 (
16-- | Take a UTF-8 string and decode it into a Unicode string.
16-- | Take a UTF-8 string and decode it into a Unicode string.
17fromUTF8 :: String -> String
17fromUTF8 :: String -> String
18fromUTF8 "" = ""
18fromUTF8 "" = ""
19+fromUTF8 ('\xef':'\xbb':'\xbf':cs) = fromUTF8 cs -- skip BOM (byte order marker)
19fromUTF8 (c:c':cs) | '\xc0' <= c && c <= '\xdf' &&
20fromUTF8 (c:c':cs) | '\xc0' <= c && c <= '\xdf' &&
20 '\x80' <= c' && c' <= '\xbf' =
21 '\x80' <= c' && c' <= '\xbf' =
21 toEnum ((fromEnum c `mod` 0x20) * 0x40 + fromEnum c' `mod` 0x40) : fromUTF8 cs
22 toEnum ((fromEnum c `mod` 0x20) * 0x40 + fromEnum c' `mod` 0x40) : fromUTF8 cs