<p>Use the text library instead? </p>
<p>On Jan 5, 2011 2:09 AM, &quot;Tony Morris&quot; &lt;<a href="mailto:tonymorris@gmail.com">tonymorris@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; I am reading files with System.IO.readFile. Some of these files start<br>
&gt; with a UTF-8 Byte Order Marker (0xef 0xbb 0xbf). For some functions that<br>
&gt; process this String, this causes choking so I drop the BOM as shown<br>
&gt; below. This feels particularly hacky, but I am not in control of many of<br>
&gt; these functions (that perhaps could use ByteString with a better solution).<br>
&gt;<br>
&gt; I&#39;m wondering if there is a better way of achieving this goal. Thanks<br>
&gt; for any tips.<br>
&gt;<br>
&gt;<br>
&gt; dropBOM ::<br>
&gt;  String<br>
&gt;  -&gt; String<br>
&gt; dropBOM [] =<br>
&gt;  []<br>
&gt; dropBOM s@(x:xs) =<br>
&gt;  let unicodeMarker = &#39;\65279&#39; -- UTF-8 BOM<br>
&gt;  in if x == unicodeMarker then xs else s<br>
&gt;<br>
&gt; readBOMFile ::<br>
&gt;  FilePath<br>
&gt;  -&gt; IO String<br>
&gt; readBOMFile p =<br>
&gt;  dropBOM `fmap` readFile p<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Tony Morris<br>
&gt; <a href="http://tmorris.net/">http://tmorris.net/</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Haskell-Cafe mailing list<br>
&gt; <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</p>