Can isdigit legitimately be locale dependent in C
Posted
by cdev
on Stack Overflow
See other posts from Stack Overflow
or by cdev
Published on 2010-05-24T15:48:32Z
Indexed on
2010/05/24
15:51 UTC
Read the original article
Hit count: 236
c
In the section covering setlocale, the ANSI C standard states in a footnote that the only ctype.h functions whose behaviour is not affected by the current locale are isdigit and isxdigit.
The Microsoft implementation of isdigit is locale dependent because, for example, in locales using code page 1250 isdigit only returns non-zero for characters in the range 0x30 ('0') - 0x39 ('9'), whereas in locales using code page 1252 isdigit also returns non-zero for the superscript digits 0xB2 ('²'), 0xB3 ('³') and 0xB9 ('¹').
Is Microsoft in violation of the C standard by making isdigit locale dependent?
In this question I am primarily interested in C90, which Microsoft claims to conform to, rather than C99.
Additional background:
Microsoft's own documentation of setlocale incorrectly states that isdigit is unaffected by the LC_CTYPE part of the locale.
The section of the C standard that covers the ctype.h functions contains some wording that I consider ambiguous:
"The behavior of these functions is affected by the current locale. Those functions that have locale-specific aspects only when not in the "C" locale are noted below."
I consider this ambiguous because it is unclear what it is trying to say about functions such as isdigit for which there are no notes about locale-specific aspects. It might be trying to say that such functions must be assumed to be locale dependent, in which case Microsoft's implementation of isdigit would be OK. (Except that the footnote I mentioned earlier seems to contradict this interpretation.)
© Stack Overflow or respective owner