Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tolower for characters with diacritics

Status
Not open for further replies.

xwb

Programmer
Jul 11, 2002
6,828
1
36
GB
Are there any standard routines that will convert characters with diacritics from upper to lowercase and vice-versa? Some of these differ by 0x20, others differ by 1.

For instance, is there anything that will convert from Ö to ö.

Also, is there anything that will convert o with all its different diacritics to o with no diacritic?
 
man page toupper said:
The details of what constitutes an uppercase or lowercase letter depend
on the current locale. For example, the default "C" locale does not
know about umlauts, so no conversion is done for them.

In some non ? English locales, there are lowercase letters with no cor?
responding uppercase equivalent; the German sharp s is one example.

SEE ALSO
isalpha(3), setlocale(3), locale(7)
Now depending on how well your OS/Compiler supports locales (and which ones it does support), this may or may not be a way forward. The general idea being by setting the right locale, you should get the effect you desire.

> Also, is there anything that will convert o with all its different diacritics to o with no diacritic?
A simple lookup table should suffice
Code:
if ( strchr( "Öö", ch ) ) return 'o'; else return ch;

--
 
I'm using lots of lookup tables at the moment: just wondering if there was a better method. Maybe space wise it isn't a much as I thought since Latin-1 doesn't have that many characters.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top