Q: Locale independant way to process special chars

Discussion in 'C++' started by Jakob Bieling, Aug 29, 2004.

  1. Hi,

    Did not really know a short subject line, which describes my question
    better. I want to figure out, if a specific character is an alphabetic
    character, without having to be locale specific. For example, even tho the
    Umlaut a (ie. 'ä') is not in part of the English alphabet, it is part of the
    German alphabet. Despite that, I would like the Umlaut a to be recognised as
    an alphabetic character, without having to switch locales; otherwise, I
    would have to loop thru all different locales, just to find out, if a
    character is part of the alphabet of any of these.

    Tho my documentation tells me that 'for iswalpha, the result of the test
    condition is independent of locale', it still returns 0 for the Umlaut a. Is
    my C++ implementation broken or did I just misunderstand something?

    Thanks!
    --
    jb

    (reply address in rot13, unscramble first)
     
    Jakob Bieling, Aug 29, 2004
    #1
    1. Advertisements

  2. Jakob Bieling

    David Hilsee Guest

    Re: Locale independant way to process special chars

    "Jakob Bieling" <> wrote in message
    news:cgsvr6$c0g$04$-online.com...
    > Hi,
    >
    > Did not really know a short subject line, which describes my question
    > better. I want to figure out, if a specific character is an alphabetic
    > character, without having to be locale specific. For example, even tho the
    > Umlaut a (ie. 'ä') is not in part of the English alphabet, it is part of

    the
    > German alphabet. Despite that, I would like the Umlaut a to be recognised

    as
    > an alphabetic character, without having to switch locales; otherwise, I
    > would have to loop thru all different locales, just to find out, if a
    > character is part of the alphabet of any of these.


    I would be surprised if there were a single standard function call that did
    what you need to do. It sounds like an odd bit of functionality that most
    people would never use. Why would you want to know if a character is an
    alpabetic character in any locale? Is a loop not feasible?

    > Tho my documentation tells me that 'for iswalpha, the result of the

    test
    > condition is independent of locale', it still returns 0 for the Umlaut a.

    Is
    > my C++ implementation broken or did I just misunderstand something?


    I would assume that this means that, for any input, the return value of
    iswalpha will not change when the current locale changes.

    --
    David Hilsee
     
    David Hilsee, Aug 29, 2004
    #2
    1. Advertisements

  3. Jakob Bieling

    David Hilsee Guest

    Re: Locale independant way to process special chars

    "Jakob Bieling" <> wrote in message
    news:cgsvr6$c0g$04$-online.com...
    <snip>
    > Tho my documentation tells me that 'for iswalpha, the result of the

    test
    > condition is independent of locale', it still returns 0 for the Umlaut a.

    Is
    > my C++ implementation broken or did I just misunderstand something?


    FWIW, std::iswalpha(L'ä') returned true on VS.NET 2003 Win2K Pro.

    --
    David Hilsee
     
    David Hilsee, Aug 29, 2004
    #3
  4. Re: Locale independant way to process special chars

    "David Hilsee" <> wrote in message
    news:...
    > "Jakob Bieling" <> wrote in message
    > news:cgsvr6$c0g$04$-online.com...
    > <snip>
    > > Tho my documentation tells me that 'for iswalpha, the result of the

    > test
    > > condition is independent of locale', it still returns 0 for the Umlaut

    a.
    > Is
    > > my C++ implementation broken or did I just misunderstand something?

    >
    > FWIW, std::iswalpha(L'ä') returned true on VS.NET 2003 Win2K Pro.



    Ah, thanks for the hint. My fault, I passed a char without converting to
    unsigned first, so the sign was expanded in the implicit conversion, which
    made it return 0. It all works now, thanks! :)
    --
    jb

    (reply address in rot13, unscramble first)
     
    Jakob Bieling, Aug 30, 2004
    #4
    1. Advertisements

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. Maurice Hulsman
    Replies:
    1
    Views:
    2,241
    Guus Bosman
    Jul 25, 2004
  2. Kosio

    Floats to chars and chars to floats

    Kosio, Sep 16, 2005, in forum: C Programming
    Replies:
    44
    Views:
    1,875
    Tim Rentsch
    Sep 23, 2005
  3. Hongyu
    Replies:
    9
    Views:
    1,260
    James Kanze
    Aug 8, 2008
  4. Replies:
    4
    Views:
    1,357
  5. zade
    Replies:
    1
    Views:
    939
    James Kanze
    Mar 5, 2010
  6. Sibylle Koczian
    Replies:
    2
    Views:
    1,388
    Sibylle Koczian
    Nov 20, 2010
  7. M.Posseth

    receiving ??? chars instead of "special" chars

    M.Posseth, Nov 15, 2004, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    518
    Dan Rogers
    Nov 16, 2004
  8. Masao Mutoh
    Replies:
    0
    Views:
    226
    Masao Mutoh
    Dec 4, 2008
Loading...