www.digitalmars.com         C & C++   DMDScript  

c++ - isupper, islower (locale)

reply Imbecil <shefututurorshefilor yahoo.com> writes:
Hi,


I think the ctype tables are wrong.
I'm getting  isupper (c, loc) == islower (c, loc)  for every c
in every loc.


Example program (which throws instead of returning 0):


//---------------------------------------------- Cut here...
#include <locale>

int main ()
{
  if (std::islower ('A', std::locale ()))
    throw 1;

  if (std::isupper ('a', std::locale ()))
    throw 2;

  return 0;
}
//---------------------------------------------- ... and here !


Ohh and BTW, shouldn't I be able to write
  islower ('A', std::locale ())
instead of std::islower (...) ?


Thank you for your time and your work on DMC. >:D<
Jan 09 2008
parent reply Sunny Pal Singh <arorasp2000 hotmail.com> writes:
Imbecil wrote:
 Ohh and BTW, shouldn't I be able to write
   islower ('A', std::locale ())
 instead of std::islower (...) ?
 

You could use using namespace std; or using std::islower; & using std::locale; in the beginning before main or before the first access to function.
Jan 23 2008
parent Imbecil <shefututurorshefilor yahoo.com> writes:
Thank you. I will do just that. :)

I am not bothered too much by having to qualify the function name
with "std::" ; I mentioned this secondary, minor issue, because
it seemed to me that there might have been a bug in the compiler.

Since the type of the second argument is "locale"
from "namespace std", I thought that "namespace std" should
have been searched for "isupper"-named functions,
according to (my possible mis-understanding of) Koenig lookup:

  Example 4 (b)
  http://www.gotw.ca/publications/mill02.htm

(The primary, major issue I had was that of wrong ctype results.)

Thanks again ! :)
Jan 25 2008