> From: Todd Zuercher [mailto:[email protected]]
> Whoever came up with the idea that we needed different characters for
> hyphens, dashes and minus signs anyway? Someone needs
> kicked.
>
> I don't remember having problems with these a few years ago.
>
> Todd Zuercher
> P. Graham Dunn Inc.
My response to your question is the last line of my post but here's the
background.
If you've ever had the experience of working on an IBM 360/370 series and
written programs using PASCAL you'll have discovered an interesting problem.
The PASCAL statement
if ch in ['A'..'Z'] then begin ... end;
won't work right.
That's because the compiler generates code that does the following test
(written now in C for example) .
if ((ch >=0xC1) && (ch <= 0xE9)) { ... };
Needless to say the PASCAL is easier to read when you understand set notation.
Trouble is, the IBMs used EBCDIC for character representation, not ASCII. To
write this in PASCAL and in C is done correctly like this:
IF (ch IN ['A'..'I']) OR (ch IN ['J'..'R']) OR (ch IN ['S'..'Z']) THEN BEGIN
... END;
In C (or in PASCAL) to use the hex values you would write it like this:
if (((ch>=0xC1) && (ch<=0xC9)) ||
((ch>=0xD1) && (ch<=0xD9)) ||
((ch>=0xE2) && (ch<=0xE9)) ) { ... };
Yikes eh? Notice the gaps. If the ch had a value 0xE1 then the all inclusive
test from 0xC1 to 0xE9 would pass even though the ch variable has an invalid
character.
No move forward in time and Embarcadero changed the OBJECT PASCAL (Delphi)
language in one fell swoop breaking thousands of programs and who knows how
many man hours were required to fix it.
The type CHAR was always 7 bit ASCII and as programs became more international
the WIDECHAR was introduced to handle 16 bit character sets and special
characters or symbols like the German umlaut.
And then suddenly a char was 16 bits and an ANSICHAR was 8 bits. Every program
out there that expected CHAR to be a 7 bit ASCII character broke. Most of the
time it didn't matter much because if it was a desktop screen application the
OS took care of a lot. If you dealt with weigh scales and serial ports or any
other hardware device that sent 8 bit characters over a UART based serial port
it was serious. Or reading a text file created by a different OS.
And with the advent of 16 bit characters we can now have all sorts of values
for what to the average eye looks like a '-'.
John Dammeyer
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users