+ return cbuf3
+
+
+-- | When converting from UTF-8 to UCS-4, Solaris iconv adds a Byte Order Mark (BOM)
+-- of value 0xfeff to the start of the stream. We don't want to return this to
+-- the caller, so strip it here. This is a safe operation for other platforms,
+-- so always do it.
+stripByteOrderMark :: CharBuffer -> IO CharBuffer
+stripByteOrderMark cbuf
+ | isEmptyBuffer cbuf
+ = return cbuf
+
+ | otherwise
+ = do firstChar <- peekCharBuf (bufRaw cbuf) 0
+ if firstChar == chr 0xfeff
+ then return (bufferRemove 1 cbuf)
+ else return cbuf