-{-# OPTIONS_GHC -XNoImplicitPrelude -XRecordWildCards #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
+{-# LANGUAGE NoImplicitPrelude, RecordWildCards #-}
+
-----------------------------------------------------------------------------
-- |
-- Module : GHC.IO.Handle
hSetEncoding hdl encoding = do
withAllHandles__ "hSetEncoding" hdl $ \h_@Handle__{..} -> do
flushCharBuffer h_
+ closeTextCodecs h_
openTextEncoding (Just encoding) haType $ \ mb_encoder mb_decoder -> do
bbuf <- readIORef haByteBuffer
ref <- newIORef (error "last_decode")
-- This operation may fail with:
--
-- * 'isIllegalOperationError' if the Handle is not seekable, or does
--- not support the requested seek mode.
+-- not support the requested seek mode.
+--
-- * 'isPermissionError' if a system resource limit would be exceeded.
hSeek :: Handle -> SeekMode -> Integer -> IO ()
withAllHandles__ "hSetBinaryMode" handle $ \ h_@Handle__{..} ->
do
flushCharBuffer h_
+ closeTextCodecs h_
let mb_te | bin = Nothing
| otherwise = Just localeEncoding