zoukankan
html css js c++ java
获取中文首字母的方法
C#实现代码
public
class
Converter
{
static
public
string
GetChineseSpell(
string
strText)
{
int
len
=
strText.Length;
string
myStr
=
""
;
for
(
int
i
=
0
; i
<
len; i
++
)
{
myStr
+=
getSpell(strText.Substring(i,
1
));
}
return
myStr;
}
static
public
string
getSpell(
string
cnChar)
{
byte
[] arrCN
=
Encoding.Default.GetBytes(cnChar);
if
(arrCN.Length
>
1
)
{
int
area
=
(
short
)arrCN[
0
];
int
pos
=
(
short
)arrCN[
1
];
int
code
=
(area
<<
8
)
+
pos;
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
}
;
for
(
int
i
=
0
; i
<
26
; i
++
)
{
int
max
=
55290
;
if
(i
!=
25
) max
=
areacode[i
+
1
];
if
(areacode[i]
<=
code
&&
code
<
max)
{
return
Encoding.Default.GetString(
new
byte
[]
{ (
byte
)(
97
+
i) }
);
}
}
return
"
*
"
;
}
else
return
cnChar;
}
}
查看全文
相关阅读:
2008 server 备份
IBM公共文档库javascript
javascript 删除节点
鼠标onfocus或onblur效果
jquery绿色版dreamweaver提示
修复IE6下 25+ Bugs
parentNode, removeChild, nextSibling, firstChild的练习
近期技术讨论贴(持续更新:1210)
png图片(有含有透明)在IE6中为什么不透明了
浅谈javascript面向对象编程
原文地址:https://www.cnblogs.com/Randy0528/p/750605.html
最新文章
C# ie通过打印控件点打印,总是弹出另存为xps的对话框
SQL Server 2008新建用户,并只给该用户读取、更新、删除,及修改表结构的权限
C# Repeater用AspNetPager分页
disuz里面的表格bbs格式,在dreamweaver中通过正则替换成html格式
C# WinFrom 对字符进行UTF8编码
JavaScript精粹读书笔记(1,2)
输出select日期
图片轮换
表单的简单练习
关于Aptana Studio生成自动备份文件的解决办法。
热门文章
分享一个漂亮的自动播放的Tabs
JS教程:详细讲解JS节点知识
一行时间的输出
css sprite
Javascript 节点 全面解析
css牛人blog
批量删除一个目录下的文件
Web标准:Img图片在IE6下显示空白的Bug解决方案
在dw下安装zen coding,并对其快捷键进行修改
JavaScript 经典效果集[第一集]
Copyright © 2011-2022 走看看