static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; // Katakana-Hankana Console.WriteLine($"========================KatakanaToHankana======================"); Console.WriteLine($"old Katakana:{Katakana}"); Console.WriteLine($"converted Hankana:{KanaConverter.Convert(Katakana, KanaOption.KatakanaToHankana)}"); Console.WriteLine(); //Hankana-Katakana Console.WriteLine($"========================HankanaToKatakana======================="); Console.WriteLine($"old Hankana:{Hankana}"); Console.WriteLine($"converted Katakana:{KanaConverter.Convert(Hankana, KanaOption.HankanaToKatakana)}"); Console.WriteLine(); // Hiragana-Hankana Console.WriteLine($"========================HiraganaToHankana======================="); Console.WriteLine($"old Hiragana:{Hiragana}"); Console.WriteLine($"converted Hankana:{KanaConverter.Convert(Hiragana, KanaOption.HiraganaToHankana)}"); Console.WriteLine(); //Hankana--Hiragana Console.WriteLine($"========================HankanaToHiragana======================="); Console.WriteLine($"old Hankana:{Hankana}"); Console.WriteLine($"converted Hiragana:{KanaConverter.Convert(Hankana, KanaOption.HankanaToHiragana)}"); Console.WriteLine(); //Katakana-Hiragana Console.WriteLine($"========================KatakanaToHiragana======================="); Console.WriteLine($"old Katakana:{Katakana}"); Console.WriteLine($"converted Hiragana:{KanaConverter.Convert(Katakana, KanaOption.KatakanaToHiragana)}"); Console.WriteLine(); //Hiragana-Katakana Console.WriteLine($"========================HiraganaToKatakana======================="); Console.WriteLine($"old Hiragana:{Hiragana}"); Console.WriteLine($"converted Katakana:{KanaConverter.Convert(Hiragana, KanaOption.HiraganaToKatakana)}"); Console.WriteLine(); //Katakana-Hiragana Console.WriteLine($"========================KatakanaToHiragana======================="); Console.WriteLine($"old KatakanaOdoriji:{KatakanaOdoriji}"); Console.WriteLine($"converted HiraganaOdoriji:{KanaConverter.Convert(KatakanaOdoriji, KanaOption.KatakanaToHiragana)}"); Console.WriteLine(); //Hiragana-Katakana Console.WriteLine($"========================HiraganaToKatakana======================="); Console.WriteLine($"old HiraganaOdoriji:{HiraganaOdoriji}"); Console.WriteLine($"converted KatakanaOdoriji:{KanaConverter.Convert(HiraganaOdoriji, KanaOption.HiraganaToKatakana)}"); Console.WriteLine(); Console.ReadLine(); }
/// <summary> /// 指定字符串替换特列字符。例如:^ ̄_ヽヾゝゞ〃仝々〆〇ー―‐/\~∥|…‥‘ 等替换成空格 /// </summary> /// <param name="originalString">原字符串</param> /// <param name="replaceString">替换字符串</param> /// <returns></returns> public static string SpecialCharactersReplaceWideSpace(this string originalString, string replaceString) { var list = _specialCharacters.ToList(); foreach (var c in list) { var n = KanaConverter.Convert(c.ToString(), KanaOption.Wide); if (originalString.Contains(n)) { originalString = originalString.Replace(n, replaceString); } } return(originalString); }
/// <summary> ///PayPay 法人格移除 /// </summary> /// <param name="originalString"></param> /// <returns></returns> public static string RemoveCompanyPhrase2(this string originalString) { var list = _companyPhrase2.OrderByDescending(r => r.Length); foreach (var c in list) { var n = KanaConverter.Convert(c.ToString(), KanaOption.Wide); if (originalString.Contains(n)) { originalString = originalString.Replace(n, ""); } } return(originalString); }
static void Main(string[] args) { //Console.WriteLine("+-*/".ToHalfWidth()); //Console.WriteLine("+-*/".ToFullWidth()); //Console.WriteLine("アイウエオ".ToHalfWidth()); //Console.WriteLine("アイウエオ".ToFullWidth()); //Console.ReadLine(); Console.OutputEncoding = Encoding.UTF8; // Katakana/Hankana Console.WriteLine($"========================KatakanaToHankana======================"); Console.WriteLine($"old Katakana:{Katakana}"); Console.WriteLine($"converted Hankana:{KanaConverter.Convert(Katakana, KanaOption.KatakanaToHankana)}"); Console.WriteLine(); Console.WriteLine($"========================HankanaToKatakana======================="); Console.WriteLine($"old Hankana:{Hankana}"); Console.WriteLine($"converted Katakana:{KanaConverter.Convert(Hankana, KanaOption.HankanaToKatakana)}"); Console.WriteLine(); // Hiragana/Hankana //Assert.Equal(Hankana, KanaConverter.Convert(Hiragana, KanaOption.HiraganaToHankana)); Console.WriteLine($"========================HiraganaToHankana======================="); Console.WriteLine($"old Hiragana:{Hiragana}"); Console.WriteLine($"converted Hankana:{KanaConverter.Convert(Hiragana, KanaOption.HiraganaToHankana)}"); Console.WriteLine(); //Assert.Equal(Hiragana, KanaConverter.Convert(Hankana, KanaOption.HankanaToHiragana)); Console.WriteLine($"========================HankanaToHiragana======================="); Console.WriteLine($"old Hankana:{Hankana}"); Console.WriteLine($"converted Hiragana:{KanaConverter.Convert(Hankana, KanaOption.HankanaToHiragana)}"); Console.WriteLine(); //// Hiragana/Katakana //Assert.Equal(Hiragana, KanaConverter.Convert(Katakana, KanaOption.KatakanaToHiragana)); Console.WriteLine($"========================KatakanaToHiragana======================="); Console.WriteLine($"old Katakana:{Katakana}"); Console.WriteLine($"converted Hiragana:{KanaConverter.Convert(Katakana, KanaOption.KatakanaToHiragana)}"); Console.WriteLine(); //Assert.Equal(Katakana, KanaConverter.Convert(Hiragana, KanaOption.HiraganaToKatakana)); Console.WriteLine($"========================HiraganaToKatakana======================="); Console.WriteLine($"old Hiragana:{Hiragana}"); Console.WriteLine($"converted Katakana:{KanaConverter.Convert(Hiragana, KanaOption.HiraganaToKatakana)}"); Console.WriteLine(); //Assert.Equal(HiraganaOdoriji, KanaConverter.Convert(KatakanaOdoriji, KanaOption.KatakanaToHiragana)); Console.WriteLine($"========================KatakanaToHiragana======================="); Console.WriteLine($"old KatakanaOdoriji:{KatakanaOdoriji}"); Console.WriteLine($"converted HiraganaOdoriji:{KanaConverter.Convert(KatakanaOdoriji, KanaOption.KatakanaToHiragana)}"); Console.WriteLine(); //Assert.Equal(KatakanaOdoriji, KanaConverter.Convert(HiraganaOdoriji, KanaOption.HiraganaToKatakana)); Console.WriteLine($"========================HiraganaToKatakana======================="); Console.WriteLine($"old HiraganaOdoriji:{HiraganaOdoriji}"); Console.WriteLine($"converted KatakanaOdoriji:{KanaConverter.Convert(HiraganaOdoriji, KanaOption.HiraganaToKatakana)}"); Console.WriteLine(); Console.ReadLine(); }