check and convert lower character to upper character

Discussion in 'C++' started by alessio211734@yahoo.it, Nov 17, 2007.

  1. Guest

    How can I check in c++ string if a character is lower or upper?
    Exist a function in c++ to convert string to upper characters?


    Thanks in advance.
    , Nov 17, 2007
    #1
    1. Advertising

  2. oogie Guest

    On Nov 17, 11:27 am, wrote:
    > How can I check in c++ string if a character is lower or upper?
    > Exist a function in c++ to convert string to upper characters?
    >
    > Thanks in advance.


    The isupper(), islower(), toupper(), and tolower() functions should
    handle this. You will need to also include the cctype header in your
    code.
    oogie, Nov 17, 2007
    #2
    1. Advertising

  3. oogie wrote:
    > The isupper(), islower(), toupper(), and tolower() functions should
    > handle this.


    Note that they might not handle correctly characters outside the ASCII
    range (such as ä, ö, etc).
    Juha Nieminen, Nov 17, 2007
    #3
  4. James Kanze Guest

    On Nov 18, 12:20 am, Juha Nieminen <> wrote:
    > oogie wrote:
    > > The isupper(), islower(), toupper(), and tolower() functions should
    > > handle this.


    > Note that they might not handle correctly characters outside the ASCII
    > range (such as ä, ö, etc).


    It's locale specific.

    Note, on the other hand, that you cannot reliably pass a char to
    the isupper() et al. functions in <cctype> without risking
    undefined behavior. For this, you need the functions in
    std::locale::ctype<char> (which is probably the better way to do
    it anyway, although it can be awfully verbose).

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
    James Kanze, Nov 18, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    700
    Jürgen Exner
    Dec 7, 2004
  2. ANM
    Replies:
    2
    Views:
    1,346
    Thomas Schodt
    Mar 7, 2004
  3. Rhiner Dan
    Replies:
    1
    Views:
    738
    Mike Wahler
    Mar 27, 2005
  4. B Williams
    Replies:
    9
    Views:
    460
    Yannick Tremblay
    Dec 19, 2006
  5. BlackHelicopter
    Replies:
    0
    Views:
    502
    BlackHelicopter
    Jan 31, 2013
Loading...

Share This Page