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));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Test if input contains a mix of Romaji and Kana, defaults to pass through Kanji.
 /// </summary>
 /// <param name="input">Input.</param>
 /// <param name="passKanji">A value indicating whether the checker should pass through kanji.</param>
 /// <returns>A value indicating whether input is mixed.</returns>
 public static bool IsMixed(string input, bool passKanji = true) => MixedChecker.IsMixed(input, passKanji);