So: it handles some accented ASCII, ligatures, Western European stuff, greek and cyrillic, while it fails on others (returning the lowercase characters themselves when they have valid uppercase variants). In at least one case, it fails utterly (the uppercase version of ÿ is Ÿ, not Y).

Mathematica’s documentation is very short on specifics on Unicode support. It broadly states that:

Mathematica has efficient systemwide 16-bit Unicode support, allowing a full range of international, technical and other character sets and character encodings.

which of course I very much doubt after seeing the above. More specifically, the ToUpperCase doc does not include a mention of Unicode.

So, after that bleak assessment, the question is the following: how do I get better Unicode-compliant string manipulation functions? (mostly ToUpperCase and ToLowerCase for now, but I'm sure others will be a problem for me in the future). Are there internal functions that do this, or external packages? Have I missed something in M’s documentation?

On a humorous note: the documentation for ToUpperCase even uses my example of a buggy transform (ÿ) in an example. It is, however, used about an unrelated issue, to warn users that “for a few characters, ToLowerCase is not the inverse of ToUpperCase” (as might be expected by Unicode-unaware programmers):

Since this issue is listed in the 'Possible Issues' section of the documentation I don't think it's likely there will be an internal solution, otherwise they would have noted that. If the list of problem cases is restricted couldn't you just redefine ToLowerCase for those cases?
–
Sjoerd C. de VriesMar 27 '12 at 21:16

1

First, the “problem” noted in the documentation is not my bug: the doc states that lowercase then uppercase is not necessarily a round trip, which is expected. I just mentioned that they unfortunately use one buggy case as part of their remark… I'll try to make my question clearer.
–
F'xMar 27 '12 at 21:21

1

Perhaps this W3.org note is related: "The CSS2 specification only requires that text-transform work for 'the Latin1 repertoire'. It is not clear what characters the term 'Latin1' covers. This test assumes that it means the Basic Latin and Latin-1 Supplement blocks of the Unicode Standard (equivalent to ISO-8859-1). There is one character in this set, ÿ, that only occurs in the lower-case form."
–
Sjoerd C. de VriesMar 27 '12 at 21:29

1

@SjoerdC.deVries yes, I actually tried ÿ because I know it's the only Latin-1 character whose uppercase variant is not included in Latin-1, so it the past it was always an interesting corner case. But Mathematica's string support is not Latin-1 based, as far as I understand. Or is it?
–
F'xMar 27 '12 at 21:32

1

And Wikipedia: "The ISO 8859-1 character encoding includes the letters ä, ë, ï, ö, ü, and their respective capital forms, as well as ÿ in lower case only, with Ÿ added in the revised edition ISO 8859-15."
–
Sjoerd C. de VriesMar 27 '12 at 21:34

I had started working on a homegrown solution to this issue, directly by downloading Unicode data from the source. I’ll post it here, as it may be expanded to other functions were Java might not come and save the day!

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.