UTF-8 string output on Mac OS terminal

I got a program in haskell that outputs utf-8 using a package utf8-stringand using only the output functions of this package.

I set the encoding of each file that I write as follows:

hSetEncoding myFile utf8
{- myFile may be stdout -}

but when I try to output:

alpha = [toEnum 0x03B1] {- α -}

instead of the pretty letter I got on Linux (or in the file on windows), I got the following:

α 

Strange, even if I try to write the output to a file, I cannot read it with mvim as utf-8. Is there a way to get the right behavior

+3
source share
2 answers

GHC 6.12 . utf8-string .

import System.IO

main                         =  do
  out alpha stdout

alpha                        =  [toEnum 0x03B1] {- α -}

out s handle                 =  do
  hSetEncoding handle utf8
  hPutStrLn handle s

, , OS X. - .

+3

Source: https://habr.com/ru/post/1747677/


All Articles