On Wed, Apr 08, 2009 at 06:55:12PM +0100, lostgallifreyan wrote: > Joshua Phillips <jp.sittingd...@gmail.com> wrote: > >For case-insensitive comparisons in C, there's strcasecmp (GNU) and stricmp > >(MSVCRT). They're both identical in function, but are non-standard > >extensions. > > No generic case comparion OR forcing in C?
Not for complete strings. There are case-folding functions for individual characters, and you can trivially case-fold a string by iterating over its content. Something like this, perhaps: for (unsigned char * p = s;*p != '\0';p++) *p = tolower(*p); > Lua is based in C Lua's "string.upper" function constructs a new string by calling C's "toupper" function on each of the original string's characters. The "string.lower" function does the same thing using "tolower". Aside: C also has case-folding functions for wide characters, but they probably aren't sufficient to handle Unicode because they just have single characters as input and output. Unicode's case folding algorithms sometimes change the string length. For example the German sharp-s is a single character in lower case but two characters in upper case, and Greek has even more complex conversions. There's also the issue that some letters fold differently based on the source language. C's locale support might be able to deal with this if you adjust the locale to match the text being processed (rather than the user environment). For example the case conversions for "i" and "I" are different in Turkish than in English. In one bizarre situation, using the English conversions on some Turkish text apparently set off a chain of events leading to multiple homicides: http://www.gizmodo.com.au/2008/04/a_cellphones_missing_dot_kills_two_people_puts_three_more_in_jail-2.html -Dave Dodge _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/tinycc-devel