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).

有帮助吗?

解决方案

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".

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top