public static string ToKatakana(string input, WanaKanaOptions?options = null)
        {
            if (input is null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            options ??= new WanaKanaOptions();

            if (input.Length == 0)
            {
                return(string.Empty);
            }

            if (options.PassRomaji)
            {
                return(KanaConverters.HiraganaToKatakana(input));
            }

            if (MixedChecker.IsMixed(input) || RomajiChecker.IsRomaji(input) || SpecialCharacterChecker.IsEnglishPunctuation(input[0]))
            {
                var hiragana = KanaConverters.ToKana(input.ToLowerInvariant(), options);
                return(KanaConverters.HiraganaToKatakana(hiragana));
            }

            return(KanaConverters.HiraganaToKatakana(input));
        }
예제 #2
0
 private static string GetTokenType(char character, bool compact = false)
 {
     if (compact)
     {
         if (IsJaNumber(character))
         {
             return(TokenTypes.Other);
         }
         if (IsEnNumber(character))
         {
             return(TokenTypes.Other);
         }
         if (IsEnSpace(character))
         {
             return(TokenTypes.English);
         }
         if (SpecialCharacterChecker.IsEnglishPunctuation(character))
         {
             return(TokenTypes.Other);
         }
         if (IsJaSpace(character))
         {
             return(TokenTypes.Japanese);
         }
         if (SpecialCharacterChecker.IsJapanesePunctuation(character))
         {
             return(TokenTypes.Other);
         }
         if (JapaneseChecker.IsJapanese(character))
         {
             return(TokenTypes.Japanese);
         }
         if (RomajiChecker.IsRomaji(character))
         {
             return(TokenTypes.English);
         }
     }
     else
     {
         if (IsJaSpace(character))
         {
             return(TokenTypes.Space);
         }
         if (IsEnSpace(character))
         {
             return(TokenTypes.Space);
         }
         if (IsJaNumber(character))
         {
             return(TokenTypes.JapaneseNumber);
         }
         if (IsEnNumber(character))
         {
             return(TokenTypes.EnglishNumber);
         }
         if (SpecialCharacterChecker.IsEnglishPunctuation(character))
         {
             return(TokenTypes.EnglishPunctuation);
         }
         if (SpecialCharacterChecker.IsJapanesePunctuation(character))
         {
             return(TokenTypes.JapanesePunctuation);
         }
         if (KanjiChecker.IsKanji(character))
         {
             return(TokenTypes.Kanji);
         }
         if (HiraganaChecker.IsHiragana(character))
         {
             return(TokenTypes.Hiragana);
         }
         if (KatakanaChecker.IsKatakana(character))
         {
             return(TokenTypes.Katakana);
         }
         if (JapaneseChecker.IsJapanese(character))
         {
             return(TokenTypes.Japanese);
         }
         if (RomajiChecker.IsRomaji(character))
         {
             return(TokenTypes.English);
         }
     }
     return(TokenTypes.Other);
 }
예제 #3
0
 /// <summary>
 /// Test if input is Romaji (allowing Hepburn romanisation).
 /// </summary>
 /// <param name="input">Input.</param>
 /// <param name="additionalCharactersRegex">Regex with additional allowed characters.</param>
 /// <returns>A value indicating whether input is romaji.</returns>
 public static bool IsRomaji(string input, Regex additionalCharactersRegex) => RomajiChecker.IsRomaji(input, additionalCharactersRegex);
예제 #4
0
 /// <summary>
 /// Test if input is Romaji (allowing Hepburn romanisation).
 /// </summary>
 /// <param name="input">Input.</param>
 /// <param name="additionalCharactersRegex">Additional allowed characters.</param>
 /// <returns>A value indicating whether input is romaji.</returns>
 public static bool IsRomaji(string input, params char[] additionalCharacters) => RomajiChecker.IsRomaji(input, additionalCharacters);
예제 #5
0
 /// <summary>
 /// Test if input is Romaji (allowing Hepburn romanisation).
 /// </summary>
 /// <param name="input">Input.</param>
 /// <returns>A value indicating whether input is romaji.</returns>
 public static bool IsRomaji(string input) => RomajiChecker.IsRomaji(input);
예제 #6
0
 /// <summary>
 /// Test if input is Romaji (allowing Hepburn romanisation).
 /// </summary>
 /// <param name="input">Input.</param>
 /// <returns>A value indicating whether input is romaji.</returns>
 public static bool IsRomaji(char input) => RomajiChecker.IsRomaji(input);