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;
}
}
查看全文
相关阅读:
一个合格的员工或者管理者是怎样炼成的
关于找不到库文件
dell md3200i mdss (企业管理) 安装的那点事儿(2)
dell md3200i mdss (企业管理) 安装的那点事儿
From 202.97.60.193 icmp_seq=48 Time to live exceeded
关于清除arp 缓存的那点事儿
ping 或者ssh 发生connect: No buffer space available 错误
考研打卡_Day047
考研打卡_Day046
考研打卡_Day045
原文地址:https://www.cnblogs.com/Randy0528/p/750605.html
最新文章
(办公)springboot配置aop处理请求.
(办公)springboot配置表单验证@Valid
(办公)springmvc->controller的统一异常层,返回json
(办公)mysql安装完,只能通过localhost访问,而不能通过本机ip访问.(转)
django 简单会议室预约(1)
转载的:Python os 和 os.path模块详解
Linux三剑客-grep
Windos framework .net 3.5规则失败
sqlserver2014部署安装
windows7下mysql8.0.18部署安装
热门文章
ORA-01950: no privileges on tablespace 'USERS'
CentOS7.6静默安装19C实例脚本 ORA-27125 [FATAL] [DBT-10322]
重启监听卡在connecting to的问题
skipping archived logs of thread 1 from sequence 29 to 46; already backed up
ORA-19625: error identifying file
ORA-07217 environment variable cannot be evaluated
RMAN 下NOARCHIVELOG和ARCHIVE模式的恢复
mysql 5.5 修改字符编码
too many open files 报错
shell 脚本中的运算
Copyright © 2011-2022 走看看