How would you write ToUpper() if it didn't exist? Bonus points for i18n and L10n
Curiosity sparked by this: http://thedailywtf.com/Articles/The-Long-Way-toUpper.aspx
How would you write ToUpper() if it didn't exist? Bonus points for i18n and L10n
Curiosity sparked by this: http://thedailywtf.com/Articles/The-Long-Way-toUpper.aspx
I dont think SO can handle the size of the unicode tables in a single posting :)
Unfortunately, it is not so easy as just char.ToUpper() every character.
Example:
Here is a sample implementation ;)
;)
Note: The unicode charts which you can find on unicode.org contain the name of the character/code point. This string will contain " SMALL " for characters which are uppercase (mind the blanks or it might match "SMALLER" and the like). Now, you can search for a similar name with "SMALL" replaced with "CAPITAL". If you find it, you've found the captial version.
I won't win the bonus points, but here it is for 7-bit ASCII:
No static table is going to be sufficient because you need to know the language before you know the correct transforms.
e.g. In Turkish
i
needs to go toİ
(U+0130) whereas in any other language is needs to go toI
(U+0049) . And thei
is the same character U+0069.Let me suggest even more bonus points for languages such as Hebrew, Arabic, Georgian and others that just do not have capital (upper case) letters. :-)
in python ..
or, if you want to do it the "wrong way"