I want to develop a hex-dump-view and have problems with characters which are not printable in the current active ANSI codepage (CP_ACP). How do I detect them and print a dot instead?
My function currently looks like this:
function HexChar(j: byte): AnsiChar;
begin
if j < $20 then result := '.'
// Dirty workaround which only supports the undefined characters of Windows-1252
else if (GetACP=1252) and ((j=$81) or (j=$8D) or (j=$8F) or (j=$90) or (j=$9D)) then result := '.'
else result := AnsiChar(j);
end;
Using Delphi XE4 and the font Courier New, the characters $81, $8D, $8F, $90, $9D are invisible. GetACP
returns 1252, so I am using Windows-1252 . According to Wikipedia, the range I discovered is not defined in Windows-1252. How can I check if the character with ordinal value j
is defined in the current active codepage or not?