改了一亿个东西,修了一亿个 BUG
This commit is contained in:
27
Utils/PinyinExtensions.cs
Normal file
27
Utils/PinyinExtensions.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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(" ", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user