I can find an ascii uppercase but is there some unicode upper / lowercase trick?
Assuming a u21 char… (I do not need to uppercase a redhaired greeneyed astronaut).
No.
There is no ‘trick’ (like the bitwise stuff you can do in ASCII) for Unicode in general. There are blocks of Unicode for which similar tricks do work, but there are many many exceptions. In fact, uppercasing depends on the language. In Turkish an uppercase i
(same code point as in English) is not I
, but a different codepoint for dotted capital I (and this is just one example). Changing case also can change the length of the text. For example, uppercase of the German sharp s letter is SS
.
For reference: UTR#21: Case Mappings
There’s zg, a community project started by @dude_the_builder, which I now maintain. It has a CaseData
module which handles Unicode case conversion.
It doesn’t do locale-aware case conversion, just the simpler ‘universal’ form defined by the Unicode Standard. Sometimes that’s enough.
@ericlang here you have another data point for “Unicode is hard”.
yes. i only support some scrabble languages and will make a upper and lowercase table myself