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;
}
}
查看全文
相关阅读:
codeforces567E. President and Roads
codeforces 573C Bear and Drawing
bzoj4160: [Neerc2009]Exclusive Access 2
bzoj1251: 序列终结者
bzoj2534: Uva10829L-gap字符串
Excel中导入到oracle使用merge into 差异性更新数据库
文件解压缩公用类
XML常用操作
密码加密解密
GridView中数据行的操作
原文地址:https://www.cnblogs.com/Randy0528/p/750605.html
最新文章
第七周动手动脑
第五周类的创建
第五周动手动脑1
第四周动手动脑
java上机
java动手动脑解析
项目日报(二)
Python对数据库的增删改查操作
项目日报(一)
运用百度api报错
热门文章
爬取新浪网的标题和网址
jequary下载
架构漫谈阅读笔记01
周进度报告(三)
logstach
DataX实战(Datax闭坑)
bzoj4027: [HEOI2015]兔子与樱花
[Ioi2005]River
Pku1947 Rebuilding Roads
阶乘之和
Copyright © 2011-2022 走看看