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
查看全文
相关阅读:
(三)索引分区知识详解
(二)SQL Server分区创建过程
(一)SQL Server分区详解Partition(目录)
表格重新加载 where 携带上次值问题
MongoDB 时差问题问题
WebAPI跨域处理
Http请求中 content-type 和 dataType 区别
那些坑
微信公众平台开发系列一 ~ 接入前的配置工作
MVC中登录页图片验证码总结
原文地址:https://www.cnblogs.com/zhangchenliang/p/1030314.html
最新文章
ruby2.0(rails)以后版本的debug
用JS画斐波那契螺旋线(黄金螺旋线)
使用CarrierWave上传图片时,多版本文件名的统一
使用RUBY生成二维码
微信公众平台出现40052错误
用javascirpt画个太极
哈夫曼树(Huffman)的JS实现
一道小学题目
C#在 64位系统下出现 “未能加载文件或程序集”错误
foreach 与 Linq的 Select 效率问题
热门文章
尝试 TFS Express 2012.3
IE8的 JS 引擎如此不堪(二)
IE8的 JS 引擎如此不堪?
SQL Server需要监控哪些计数器
SQL Server性能计数器部署(批量)
PerfMon.exe通过命令管理计数器
TypePerf.exe使用命令查找计数器
开放数据库互联ODBC配置(odbcconf)
(五)SQL Server分区自动化案例
(四)SQL Server分区管理
Copyright © 2011-2022 走看看