The evaluation of chr 232
returns '\232'
instead of 'è'
.
Of course, I expected (chr . ord) 'è'
to return 'è'
. Instead, I got '\232'
Could someone explain what's happening, here ?
The evaluation of chr 232
returns '\232'
instead of 'è'
.
Of course, I expected (chr . ord) 'è'
to return 'è'
. Instead, I got '\232'
Could someone explain what's happening, here ?
Haskell will show as representation of a character a backslash (\
) followed with the decimal codepoint for most non-ASCII characters. The representation of a Char
will also be surrounded with single quotes ('…'
).
If you want to print the content of a string, you can work with putChar :: Char -> IO ()
:
Prelude Data.Char> putChar (chr 232)
èPrelude Data.Char>
or you can wrap it in a singleton list and use putStrLn
to print a line with that character:
Prelude Data.Char> putStrLn [chr 232]
è