I know the Z-machine can do Unicode, sort of; but I’m bogging down on the details. How do I print an em-dash (Unicode U+2014), assuming I’m using Inform 6? Does the ability to display Unicode also depend on my interpreter? I’m most concerned with Parchment (ZVM, I think), but also interested in Frotz and/or Fizmo in a Linux terminal (UTF-8).
Printing Unicode will depend on the capabilities of your interpreter and its display environment, including what fonts it has access to, but these days I would expect most interpreters to handle it pretty well.
print "@{2014}"
For this to work the character needs to be entered into the Zcharacter table, which has a few free slots (though not many). This would involve having a declaration at the top of the Inform 6 source like
Zcharacter table + '@{2014}';
It’s often easier to just use the @print_unicode opcode from the Z-Machine 1.0 specification, like this:
@print_unicode $2014;
There’s a little test file (Unicode.z5 and Unicode.inf) I wrote for testing such things that comes with Windows Frotz, which might help. Also worth reading is Roger Firth’s Inform 6 FAQ entry on Unicode handling: http://www.firthworks.com/roger/informfaq/aa20.html
Web interpreters will have the best unicode support because browsers automatically find fonts with the characters you need if your normal font doesn’t have them.
Awesome! thanks! I had been trying almost exactly your first method, but without the “+” in the Zcharacter line. (Which now doesn’t seem to make a difference.) Looks like Linux “frotz” doesn’t do Unicode; everything comes through as question marks. But Linux “fizmo” does the right thing, and so does Parchment, via either method (Zcharacter plus “@{2014}”, or @print_unicode).
Fortunately, Roger Firth’s FAQ provides the solution!
[ Unicode c substitute exist;
if (0-->31 < 1) { print (string) substitute; return; }
@check_unicode c -> exist;
if (exist & $0001) @print_unicode c;
else print (string) substitute;
];
Called as Unicode($2014, “–”), this does what I want.