zoukankan
html css js c++ java
得到汉字首字母
Code
1
static
public
string
GetChineseSpell(
string
strText)
2
{
3
int
len
=
strText.Length;
4
string
myStr
=
""
;
5
for
(
int
i
=
0
;i
<
len;i
++
)
6
{
7
myStr
+=
getSpell(strText.Substring(i,
1
));
8
}
9
return
myStr;
10
}
11
12
13
14
static
public
string
getSpell(
string
cnChar)
15
{
16
byte
[] arrCN
=
Encoding.Default.GetBytes(cnChar);
17
if
(arrCN.Length
>
1
)
18
{
19
int
area
=
(
short
)arrCN[
0
];
20
int
pos
=
(
short
)arrCN[
1
];
21
int
code
=
(area
<<
8
)
+
pos;
22
int
[] areacode
=
{
45217
,
45253
,
45761
,
46318
,
46826
,
47010
,
47297
,
47614
,
48119
,
48119
,
49062
,
49324
,
49896
,
50371
,
50614
,
50622
,
50906
,
51387
,
51446
,
52218
,
52698
,
52698
,
52698
,
52980
,
53689
,
54481
}
;
23
for
(
int
i
=
0
;i
<
26
;i
++
)
24
{
25
int
max
=
55290
;
26
if
(i
!=
25
) max
=
areacode[i
+
1
];
27
if
(areacode[i]
<=
code
&&
code
<
max)
28
{
29
return
Encoding.Default.GetString(
new
byte
[]
{(
byte
)(
65
+
i)}
);
30
}
31
}
32
return
"
*
"
;
33
}
34
else
return
cnChar;
35
}
36
查看全文
相关阅读:
CRM 2013 相关下载 / 2013-10-11
四十,Importer extension 主要(/imports)
三十九,GeoWebCache 播种和截断(/seed)
三十八,GeoWebCache 重新加载(/reload)
三十七,GeoWebCache 质量截断(/statistics)
三十六,GeoWebCache 质量截断(/masstruncate)
三十五,GeoWebCache 图层(/layers)
三十四,GeoWebCache 主页(/index)
三十三,GeoWebCache 网格集(/gridsets)
三十二,GeoWebCache 全局配置(/global)
原文地址:https://www.cnblogs.com/zhangchenliang/p/1030314.html
最新文章
.NET Core:路由
.NET Core:API文档
.NET Core:依赖注入
.NET Core:多样的宿主
部署ionic开发环境
ABAP案例:灵活读取SAP各表的数据
Office组件无法正常使用的解决方法
ieda maven加载 XPackTransportClient jar报错
win搭建vue3.0开发环境
linux同步系统时间
热门文章
UFW防火墙配置
内存盘tmpfs和ramdisk的区别
freeswitch 配置wss访问
freeswitch1.8安装
WEBRTC 01
Docket 第五章
Docket 第四章
50个常用SQL语句
[摘]在ASP.NET MVC中使用DropDownList
Microsoft Dynamics CRM 2013 的相关更新 2013-12
Copyright © 2011-2022 走看看