|
2 | 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. |
3 | 3 | // Website: https://www.blazor.zone or https://argozhang.github.io/ |
4 | 4 |
|
| 5 | +using System.Text; |
| 6 | + |
5 | 7 | namespace BootstrapBlazor.Components; |
6 | 8 |
|
7 | | -class PinYinService |
| 9 | +static class PinYinService |
8 | 10 | { |
9 | | - public static Dictionary<string, string> codes = new() |
| 11 | + public static string GetFirstLetters(string text) |
| 12 | + { |
| 13 | + var ret = new StringBuilder(); |
| 14 | + foreach (var c in text) |
| 15 | + { |
| 16 | + foreach (var item in Cache) |
| 17 | + { |
| 18 | + if (item.Value.Contains(c, StringComparison.InvariantCulture)) |
| 19 | + { |
| 20 | + ret.Append(item.Key.First()); |
| 21 | + } |
| 22 | + } |
| 23 | + } |
| 24 | + return ret.ToString().ToUpperInvariant(); |
| 25 | + } |
| 26 | + |
| 27 | + public static Dictionary<string, string> Cache = new() |
10 | 28 | { |
11 | 29 | { "a", "阿啊吖嗄腌锕" }, |
12 | 30 | { "ai", "爱埃碍矮挨唉哎哀皑癌蔼艾隘捱嗳嗌嫒瑷暧砹锿霭" }, |
@@ -46,7 +64,7 @@ class PinYinService |
46 | 64 | { "chen", "陈沉称衬尘臣晨郴辰忱趁伧谌谶抻嗔宸琛榇碜龀" }, |
47 | 65 | { "cheng", "成程称城承乘呈撑诚橙惩澄逞骋秤丞埕噌枨柽塍瞠铖铛裎蛏酲" }, |
48 | 66 | { "chi", "持尺齿吃赤池迟翅斥耻痴匙弛驰侈炽傺坻墀茌叱哧啻嗤彳饬媸敕眵鸱瘛褫蚩螭笞篪豉踟魑" }, |
49 | | - { "chong", "虫充冲崇宠茺忡憧铳舂艟" }, |
| 67 | + { "chong", "虫重充冲崇宠茺忡憧铳舂艟" }, |
50 | 68 | { "chou", "抽仇臭酬畴踌稠愁筹绸瞅丑俦帱惆瘳雠" }, |
51 | 69 | { "chu", "出处除初础触楚锄储橱厨躇雏滁矗搐亍刍怵憷绌杵楮樗褚蜍蹰黜" }, |
52 | 70 | { "chuai", "揣搋啜膪踹" }, |
|
0 commit comments