HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Moduleencoding-0.10.3Haskell2010

System.IO.Encoding

This module provides a replacement for the normal (unicode unaware) IO functions of haskell. By using implicit parameters, it can be used almost as a drop-in replacement. For example, consider the following simple echo program:

main = do
  str <- getContents
  putStr str

To make this program process UTF-8 data, change the program to:

{-# LANGUAGE ImplicitParams #-}

import Prelude hiding (getContents,putStr)
import System.IO.Encoding
import Data.Encoding.UTF8

main = do
  let ?enc = UTF8
  str <- getContents
  putStr str

Or, if you want to use the standard system encoding:

{-# LANGUAGE ImplicitParams #-}

import Prelude hiding (getContents,putStr)
import System.IO.Encoding

main = do
  e <- getSystemEncoding
  let ?enc = e
  str <- getContents
  putStr str
  • 19 values
  • Packageencoding-0.10.3
  • Exports19
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceEncoding.hs

On unix machines, returns the system's currently configured text encoding, or Nothing if there was an error. On Windows, currently always returns Nothing.