28 lines
629 B
C#
28 lines
629 B
C#
using NPinyin;
|
|
using System;
|
|
|
|
namespace AnotherReplayReader.Utils
|
|
{
|
|
static class PinyinExtensions
|
|
{
|
|
public static bool ContainsIgnoreCase(this string self, string? s)
|
|
{
|
|
return s != null && self.IndexOf(s, StringComparison.CurrentCultureIgnoreCase) != -1;
|
|
}
|
|
|
|
public static string? ToPinyin(this string self)
|
|
{
|
|
string pinyin;
|
|
try
|
|
{
|
|
pinyin = Pinyin.GetPinyin(self);
|
|
}
|
|
catch
|
|
{
|
|
return null;
|
|
}
|
|
return pinyin.Replace(" ", "");
|
|
}
|
|
}
|
|
}
|