Locale-independent case conversion

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
User avatar
Posts: 12321
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Locale-independent case conversion

Postby doublemax » Thu Jun 07, 2012 1:09 pm

The following code is based on this table: http://unicode.org/Public/UNIDATA/CaseFolding.txt

It handles only the simple cases, where the conversion from lower to upper-case is reversible. There are some exceptions, for example in German where the lower-case "ß" is converted to uppercase "SS", but the uppercase "SS" can be either "ß" or "ss" in lower case depending on the word/context.

These are simple functions in a global namespace, not optimized for speed. Feel free to use/edit/optimize at will.
This is not heavily tested, so use at your own risk ;)

Simple usage example:

Code: Select all

#include "case_conversion.h"

wxString s("äöüÄÖÜ áóéúí âôêûî");
wxLogMessage( ToUpper(s) );
wxLogMessage( ToLower(s) );
(4.38 KiB) Downloaded 178 times
Use the source, Luke!

Return to “The Code Dump”

Who is online

Users browsing this forum: No registered users and 1 guest