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
查看全文
相关阅读:
Mybatis中tinyint(1)数据自动转化为boolean处理
使用spring-cloud-starter-bus-amqp做微服务配置刷广播,config-client配置 未刷新的 问题
深入Spring Boot: 怎样排查 java.lang.ArrayStoreException
springboot activiti 配置项详解
MySQL_插入更新 ON DUPLICATE KEY UPDATE
Maven:mirror和repository 区别
ajax请求二进制流图片并渲染到html中img标签
不要在工作中做滥竽充数的人
获取客户端IP地址的三个HTTP请求头的区别
web服务器获取请求客户端真实地址的方法
原文地址:https://www.cnblogs.com/zhangchenliang/p/1030314.html
最新文章
如何创建 Swarm 集群?- 每天5分钟玩转 Docker 容器技术(95)
Docker Swarm 中最重要的概念- 每天5分钟玩转 Docker 容器技术(94)
Linux驱动开发—— of_property_read_u8
Linux基礎知識 —— open&close
Linux驱动开发—— IS_ENABLED
编译lsusb
第十章 內核同步的方法
第九章 內核同步介紹
第八章 下半部和推後執行的工作
第七章 中斷和中斷處理
热门文章
第六章 內核數據結構
第五章 系統調用
第四章 進程調度
第三章 進程管理
第二章 從內核出發
第一章 Linux內核簡介
設置Linux保留物理內存並使用 (1)
[已解决]Can't update: no tracked branch
在Eclipse上安装Activiti插件
IDEA Activiti Designer插件---actiBPM汉字乱码问题
Copyright © 2011-2022 走看看