Domanda

I need to convert an int to its equivalent char using the Char.chr-function, but why does the function return every char in the form of #"\^A" instead of just #"A" (that's how I want it to be).

È stato utile?

Soluzione

What you see there is just the way control characters (ASCII code 0-31) are pretty-printed by the interactive toplevel. For example, #"\^A" is equivalent to #"\001". The SML system presumably uses its own Char.toString function to print values of type char. Try chr 65, which should be printed as #"A".

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top