Search code examples
smlpolyml

Printing Unicode Characters in Poly/ML


How can I print a lowercase Greek epsilon in SML (using Poly/ML)?

I've tried the following:

print "ε"; (* Error-unprintable character found in file *)
print "\u03B5"; (* Error-Conversion exception (Invalid string constant) raised while converting \u03B5 to string *)

Is this simply not possible? Surely it is the job of the terminal to actually render the character, and therefore printing the raw character code to stdout should be possible?


Solution

  • The Unicode escape sequence \u03B5 corresponds to UTF-16.

    Your terminal probably runs UTF-8 in which ε is 0xCE 0xB5. Entering them as decimal bytes:

    > print "\206\181\n";
    ε