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;
}
}
查看全文
相关阅读:
Editplus中添加System.out.println()快捷键
API使用
项目有两个红点
no console to display at this time
startup.bat闪退问题
filter的dispatcher节点
【DP专题】——洛谷P2467地精部落
输入年月日,计算这是该年中第几天
输出N以内的完整数
python中关于EOF的tips
原文地址:https://www.cnblogs.com/Randy0528/p/750605.html
最新文章
DAY 14 PYTHON入门
DAY 13 PYTHON入门
DAY 12 PYTHON入门
DAY 11 PYTHON入门
DAY 10 PYTHON入门
DAY 09 PYTHON入门
DAY 08 PYTHON入门
DAY 07 PYTHON入门
AttributeError: 'dict' object has no attribute 'iteritems' python3报错
python的sorted() 函数
热门文章
python3中numpy函数的argsort()
python3中sum
python3中numpy函数tile的用法
《机器学习实战》---第二章 k近邻算法 kNN
《机器学习实战》---NumPy
python课程:python3函数
开关电源 1
以为是tomcat出现using问题,怎么改都改不好终于找到原因
javac编译出现需要标识符问题解决
不让Editplus保存时java文件时生成.bak文件
Copyright © 2011-2022 走看看