Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7894303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:21:41+00:00 2026-06-03T07:21:41+00:00

The various is… functions (e.g. isalpha , isdigit ) in ctype.h aren’t entirely predictable.

  • 0

The various is... functions (e.g. isalpha, isdigit) in ctype.h aren’t entirely predictable. They take int arguments but expect character values in the unsigned char range, so on a platform where char is signed, passing a char value directly could lead to undesirable sign extension. I believe that the typical approach to handling this is to explicitly cast to an unsigned char first.

Okay, but what is the proper, portable way to deal with the various isw... functions in wctype.h? wchar_t, like char, also may be signed or unsigned, but because wchar_t is itself a typedef, a typename of unsigned wchar_t is illegal.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:21:43+00:00Added an answer on June 3, 2026 at 7:21 am

    Upon re-reading the ISO C99 specification regarding wctype.h, it states:

    For all functions described in this subclause that accept an argument of type wint_t, the value shall be representable as a wchar_t or shall equal the value of the macro WEOF. If this argument has any other value, the behavior is undefined. (§7.25.1/5)

    Contrast this with the corresponding note for ctype.h:

    In all cases the argument is an int, the value of which shall be
    representable as an unsigned char or shall equal the value of the macro EOF. If the argument has any other value, the behavior is undefined. (§7.4/1)

    (emphasis mine)

    I think that it’s also worth understanding the motivation for why the ctype.h functions require unsigned char representations. The standard requires that EOF be a negative int (§7.19.1/3), so the ctype.h functions use unsigned char representations to (try to) avoid potential ambiguity.

    In contrast, that motivation doesn’t exist for wctype.h functions. The standard makes no such requirement of WEOF, elaborated by footnote 270:

    The value of the macro WEOF may differ from that of EOF and need not be negative.

    because WEOF is already guaranteed to not conflict with any character represented by wchar_t (§7.24.1/3).

    Therefore the wctype.h functions don’t have or need any of the unsigned nonsense, and wchar_t values can be passed to them directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On various places they said that you should use @ManagedProperty to get a request
Various connections - e.g. those created with twisted.web.client.getPage() seem to leak - they hang
Checked various questions on SO, but found nothing that quite matches what I'm after...
For various varieties of Windows and IEs virtual machines work perfectly. But how do
Various incarnations of this question have been asked here before, but I thought I'd
For various reasons that aren't too germane to the question, I've got a table
For various reasons (and I assure you they are valid, so no use Cocoa
The various performSelector:... methods can handle a maximum of two arguments passed to the
Tried various avenues but no luck. I am using a MBP with 10.7.4. I
Various JavaScript libraries (e.g. jQuery) offer an each method: $.each(myObj, myFunc); What's the advantage

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.