How to convert Char to Int in Haskell?
You can use the ord
function to convert a character to its integer (ordinal) representation.
chr
goes the other direction.
> ord '\x2'
=> 2
> chr 97
=> 'a'
> ord (chr 42)
=> 42
You can use fromEnum or Data.Char.ord.