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
查看全文
相关阅读:
TCP服务器是否需要心跳包?
用最简单的函数实现功能:判断一个int数据是否是2的x次幂(不能使用循环)。
防止程序启动两次的方法CreateMutex()
WINDOWS操作系统中可以允许最大的线程数
setsockopt 设置socket 详细用法
我的结论:DX9不支持非2的次幂尺寸纹理,还得显卡说了算
D3DX_DEFAULT_NONPOW2
【解决】Select网络模型问题——奇怪的发送接收问题
CRC32 简单使用
.NET开发总结 2010年2月
原文地址:https://www.cnblogs.com/zhangchenliang/p/1030314.html
最新文章
PetShop4.0安装的几个错误和解决方法
C#制作MDI窗体
如何确保应用只有一个实例运行
提供2006年下半年软件设计师的答案
创建站点计数器
Visual Studio 2005项目模板丢失的解决办法
VS2005中设置网格布局
提高磁盘清理速度的方法
[转]C#中正则表达式的应用
使用 Fiddler 检测本机的 HTTP 访问
热门文章
使用 jQuery dataTables 1
使用 jQuery dataTables 2 四种数据来源
使用 jQuery UI Dialog
园子的新书 《ASP.NET 本质论》
svn 的一些资料
ASP.NET MVC3 Service Location
ASP.NET MVC 3 概述
在没有安装 ASP.NET MVC3 的服务器上运行 MVC3
jQuery UI dialog 的使用
完成端口(Completion Port)详解
Copyright © 2011-2022 走看看