Tue 26 Aug 2008 06:36:38 AM UTC, original submission:
Actionscript has two case conversion methods: the old and deprecated global toUpper / toLower methods, which cannot deal with UTF-8 and the String.toUpperCase / String.toLowerCase.
The String methods can convert any of the 65535 unicode characters supported in Flash to upper or lower case (when such a thing exists in the character set).
The first method is easy to implement by using toupper with the standard POSIX locale.
The second method can be implemented using any UTF-8 locale on GNU/Linux. The following test shows a small difference in the number of characters seen to have a lower and upper case, but the discrepancy is probably not a problem:
c = 0;
for (i = 128; i < 10000; ++i) {
f = chr(i);
if (f != f.toUpperCase()) {
trace (i + ": " + f + "-" + f.toUpperCase());
c++;
}
}
trace (c);
However, we can't rely on a valid UTF-8 locale being available. Older distros, particularly in the US, use the POSIX locale and have no utf-8 locale installed, so the tests fail. Worse, Gnash will abort if a locale is specified (LC_ALL=UTF-8, for instance) that it can't find.
So a portable solution is needed: either (a) make sure a suitable locale is installed, (b) use an external library, or (c) write our own code.
(a) is difficult to do portably, especially to get it to work reliably with compiled code. As the locale object is constructed at runtime, it will throw an exception if it's not found. Locale names are implementation-dependent.
(b) ICU might be a candidate. Glib / pango can also do it, I think.
(c) would be ugly and difficult.
I'm fairly sure the pp doesn't use system locales for its case conversion.
|