Character literals between #128 and #255 – the so-called high ASCII values – have a specific value depending on the ANSI code page. As a result, we should not use the #128..#255 character literals, but use the actual characters themselves which will end up as Unicode characters in the source code.

(*$HIGHCHARUNICODE OFF*)

With the HIGHCHARUNICODE set to OFF, we can define the high-ASCII values without them turning into Unicode characters.

(*$HIGHCHARUNICODE OFF*)var C: AnsiChar;begin C := #128;

Without turning HIGHCHARUNICODE OFF, we would get a warning that the #128 character, actually WideChar constant #$0080 (based on the current active code page), would have to be narrowed from WideChar to AnsiChar.

This tip is the 6th in a series of Unicode tips taken from my Delphi 2009 Development Essentials book published earlier this week on Lulu.com.