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)); }
public void IsEnglishPunctuationAllJapanesePunctuationsAreInvalid() { foreach (var range in CharacterRanges.JapanesePunctuationRanges) { for (char character = range.Start; character <= range.End; character++) { Assert.False(SpecialCharacterChecker.IsEnglishPunctuation(character)); } } }
public void IsEnglishPunctuationAllEnglishPunctuationsAreRecognized() { foreach (var range in CharacterRanges.EnglishPunctuationRanges) { for (char character = range.Start; character <= range.End; character++) { Assert.True(SpecialCharacterChecker.IsEnglishPunctuation(character)); } } }
public void IsEnglishPunctuationVarious(char character, bool expectedResult) { Assert.Equal(expectedResult, SpecialCharacterChecker.IsEnglishPunctuation(character)); }
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); }