DavidKinder / Inform6

The latest version of the Inform 6 compiler, used for generating interactive fiction games.
http://inform-fiction.org/
Other
204 stars 34 forks source link

"@{5E}" and "@{7E}" escapes are wrong in Z-code #249

Open erkyrath opened 1 year ago

erkyrath commented 1 year ago

You're supposed to be able to escape string characters in two ways: "@@DEC" and "@{HEX}". The latter is newer and supports any Unicode value.

However, the hex form doesn't come out right for a couple of characters:

    print "@@92 is backslash, @@64 is atsign, @@94 is caret, @@126 is tilde.^";
    print "@{5C} is backslash, @{40} is atsign, @{5E} is caret, @{7E} is tilde.^";

\ is backslash, @ is atsign, ^ is caret, ~ is tilde. \ is backslash, @ is atsign, is caret, " is tilde.

That is, "@{5E}" is interpreted as "^" which is then interpreted as a newline. "@{7E}" similarly gets double-interpreted as a quote character.

(In Glulx both lines print the same thing, as expected.)

This bug goes back to 6.31 (at least) so it might not be desirable to fix it. Some old Z-code games might depend on this behavior, inconsistent as it is. But it's worth noting.