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;
}
}
查看全文
相关阅读:
MapReduce TFIDF 案列
MapReduce PageRank案列
MapReduce好友推荐案例
MapReduce天气查询实列
MapReduce源码分析
Tiny6410之LED裸机驱动
Linux -- objdump (待继续完善)
Linux -- xxd 整理自man 手册 (MARK)
Linux -- xxd (转)
tar -- 打包压缩文件
原文地址:https://www.cnblogs.com/Randy0528/p/750605.html
最新文章
CS:APP 06 笔记
CS:APP datalab
位运算实现三元表达式
浮点数不用补码表示
溢出与类型转换
ES6常用语法总结
fetch是什么?写一个fetch请求
面试题
vue axios请求频繁时取消上一次请求
前端css图片固定宽高问题
热门文章
喵喵电影git操作
超容易理解的call()、apply()、bind()的区别
面试题
github操作
搞清clientHeight、offsetHeight、scrollHeight、offsetTop、scrollTop,innerWidth, innerHeight
Hive DML
HIVE分区
HIVE的入门
Hive的搭建环境
Hive 基础
Copyright © 2011-2022 走看看