Short answer: you add 96 to the unicode value of hiragana (γΎ) to get the equivalent katakana (γ).
You can determine if the character is a hiragana by checking that the unicode value falls in the range 3040-309F.
Unfortunately, as Noah mentions, many names are written using kanji: an alphabet of about 40,000 characters each with hiragana equivalents and many contextual ones for their surroundings. If you want to support them, you will need to find a Japanese language library that will help you.
FYI, katakana is sometimes used to represent capital letters to explain their use here. (Given the preferences of the lower case Metro, I would think that a katakana is better suited)
If you only want to support hiragana, here is something that should help:
const int KatakanaStartCode = 0x30A0; const int HiraganaStartCode = 0x3040; const int HiraganaEndCode = 0x309F; private char GetGroupChar(string name) {
And then:
string name = "γΎγγͺ γγͺγγ"; char s = GetGroupChar(name); Debug.WriteLine(s);
Richard Szalay
source share