+{-# LANGUAGE CPP
+ , NoImplicitPrelude
+ , RecordWildCards
+ , BangPatterns
+ , PatternGuards
+ , NondecreasingIndentation
+ , MagicHash
+ , ForeignFunctionInterface
+ #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
{-# OPTIONS_HADDOCK hide #-}
-{-# LANGUAGE NoImplicitPrelude, RecordWildCards, BangPatterns #-}
-----------------------------------------------------------------------------
-- |
import GHC.IO.Buffer
import qualified GHC.IO.BufferedIO as Buffered
import GHC.IO.Exception
+import GHC.IO.Encoding.Failure (surrogatifyRoundtripCharacter, desurrogatifyRoundtripCharacter)
import GHC.Exception
import GHC.IO.Handle.Types
import GHC.IO.Handle.Internals
else do c1 <- peekElemOff pbuf (i-1)
let c = (fromIntegral c1 - 0xd800) * 0x400 +
(fromIntegral c2 - 0xdc00) + 0x10000
- unpackRB (unsafeChr c : acc) (i-2)
+ unpackRB (desurrogatifyRoundtripCharacter (unsafeChr c) : acc) (i-2)
#else
c <- peekElemOff pbuf i
- unpackRB (c:acc) (i-1)
+ unpackRB (desurrogatifyRoundtripCharacter c:acc) (i-1)
#endif
in
unpackRB acc0 (w-1)
then unpackRB ('\n':acc) (i-2)
else unpackRB ('\n':acc) (i-1)
else do
- unpackRB (c:acc) (i-1)
+ unpackRB (desurrogatifyRoundtripCharacter c:acc) (i-1)
in do
c <- peekElemOff pbuf (w-1)
if (c == '\r')
else do
shoveString n' cs rest
| otherwise = do
- n' <- writeCharBuf raw n c
+ n' <- writeCharBuf raw n (surrogatifyRoundtripCharacter c)
shoveString n' cs rest
in
shoveString 0 s (if add_nl then "\n" else "")