Localization: problems with toupper/tolower transformations of latin characters.

Jan Pfeifer pfjan@yahoo.com.br
Sun Dec 11 20:33:00 GMT 2005


Just noticed I did something silly. My input is UTF-8, so the latin
characters will be multibyte. The tolower/toupper had no way to know how
to handle it.

So I converted everything to wchar_t, and it worked for both versions.

A got a hint for the C++ version in libstdc++ list: I needed decoupling
the wcout from the underlying stdio (?? I guess that's what
'ios::sync_with_stdio(false);' does).

And in C one needs to use the w-functions: wcslen, wcscpy, towlower,
towupper.

thanks,

- jan


Jan Pfeifer wrote:

>hi all,
>
>I was trying to get propper transformation for upper/lower case
>characters in a generic way, at first in C++, but I noticed that the
>libc is apparently not converting correctly the latin characters.
>
>Running the attached code, that tries the C++ and C functions -- later I
>found out that libstdc++ uses libc for these, I get:
>
>$ ./test
>C++ version:
>Órfão       (original string)
>ÓRFãO   (should be upper case string)
>Órfão    (should be lower case string)
>
>C version:
>Órfão
>ÓRFãO
>Órfão
>
>
>Any ideas about what I could be missing ? Or is the library missing ?
>
>(I tried different locales, as commented in the code, and using UTF-8
>for encoding)
>
>
>thanks in advance for any help/pointers!
>
>- jan
>
>ps.:
>$ gcc --version
>gcc (GCC) 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)
>Copyright (C) 2005 Free Software Foundation, Inc.
>This is free software; see the source for copying conditions.  There is NO
>warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
>  
>

	

	
		
_______________________________________________________ 
Yahoo! doce lar. Faça do Yahoo! sua homepage. 
http://br.yahoo.com/homepageset.html 



More information about the Gcc-help mailing list