Oliver Fromme wrote:
Artem Kuchin wrote:
I have a very stupid problem. I cannot convert to upper
or lower case using manually set locale (setlocale(..)).

A very simple program:
[...]
        printf("IS UPPER ?: %d\n",isupper('?'));
        printf("IS UPPER ?: %d\n",isupper('?'));
        printf("IS LOWER ?: %d\n",islower('?'));
That's a common pitfall.  Chars are signed by default on
FreeBSD, and the isupper() etc. function take an int type
argument.  That means that characters >= 128 end up as
negative numbers, so they fail all isupper() and islower()
checks, and toupper()/tolower() don't touch them at all.

The solution is to typecast the constants to unsigned char
explicitly, like this:  isupper((unsigned char) '?') etc.
Your program will work fine then.

My stupid. I should've noticed that. Thank you very much!
Issue closed.

--
Regards,
Artem


_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to