public string HiraganaToKatakana(string hiragana)
 {
     if (JapaneseKanaClassifier.IsHiragana(hiragana))
     {
         StringBuilder resultBuilder = new StringBuilder(hiragana.Length);
         foreach (char character in hiragana)
         {
             resultBuilder.Append((char)(character - (0x3040 - 0x30A0)));
         }
         return(resultBuilder.ToString());
     }
     throw new FormatException("The given string is not valid hiragana.");
 }
        public string RomajiToHiragana(string romaji)
        {
            string result = KatakanaToHiragana(RomajiToKatakana(romaji));

            // Some last fixes
            result = result.Replace("くぁ", "くゎ"); // kwa
            result = result.Replace("どぅ", "づ");  // du
            result = result.Replace("ぐぁ", "ぐゎ"); // kwa
            result = result.Replace("すぃ", "し");  // si

            if (!JapaneseKanaClassifier.IsHiragana(result))
            {
                throw new FormatException("The argument is not valid japanese romaji (" + romaji + ")");
            }
            return(result);
        }
 public string KatakanaToHiragana(string katakana)
 {
     if (JapaneseKanaClassifier.IsHalfwidthKatakana(katakana))
     {
         katakana = katakana.Normalize(NormalizationForm.FormKC);
     }
     if (JapaneseKanaClassifier.IsFullwidthKatakana(katakana))
     {
         StringBuilder resultBuilder = new StringBuilder(katakana.Length);
         foreach (char character in katakana)
         {
             resultBuilder.Append((char)(character + (0x3040 - 0x30A0)));
         }
         return(resultBuilder.ToString());
     }
     throw new FormatException("The given string is not valid katakana.");
 }