Can isdigit legitimately be locale dependent in C

前端 未结 2 1510
刺人心
刺人心 2020-12-07 00:26

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

相关标签:
2条回答
  • 2020-12-07 01:00

    The required character set is defined in section 2.2.1. Section 2.2.1.2 then goes on to describe the behavior of extension characters:

    • The single-byte characters defined in $2.2.1 shall be present.
    • The presence, meaning, and representation of any additional members is locale-specific.
    0 讨论(0)
  • 2020-12-07 01:17
    1. Microsoft is always right.
    2. If Microsoft is not right see Item 1

    Microsoft always has its own interpretation of the spec. And usually the sentence “but Microsoft is wrong” does not carry any weight with your CEO, so you have to code around MS bugs/interpretations.

    The amount of code to support incorrect behavior of IE and Outlook is staggering.

    In many cases, the only solution is to roll your own version of the function that does the right thing and do something like this:

    int my_isdigit( int c )
    {
    #ifdef WIN32
      your implementation goes here
    #else
      return isdigit( c );
    #endif
    }
    
    0 讨论(0)
提交回复
热议问题