Pilcrow <> writes:
> Is there a way that a proram can detect whether it is operating in an
> ASCII or an EBCDIC environment?
As others have suggested, testing the numeric values of some
characters will probably tell you.
But note that there are several different variants of EBCDIC. As for
ASCII, remember that it's only a 7-bit character set. There are
numerous larger sets based on ASCII. There are the 8-bit ISO 8859-N
sets, with N running from 1 to about 15 last I heard. There's
Unicode. There's a Windows-specific 8-bit extension to ASCII. And
there are national variants that replace some of the punctuation
characters with accented letters, though these aren't used much
anymore.
If at all possible, it's better to write your code so it will work
with *any* character set. For example, if you want to know whether a
character is a lowercase letter, don't use (c >= 'a' && c <= 'z'), use
isascii(unsigned char(c)).
What problem are you really trying to solve?
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"