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;
}
}
查看全文
相关阅读:
seaborn可视化NOTE
快速入门pandas
protege下载安装使用
用上Latex实现编辑伪代码
决策树可视化
关于时间
地理三维模型制作
Python使用记录
编码格式
素数生成算法小结
原文地址:https://www.cnblogs.com/Randy0528/p/750605.html
最新文章
java8新特性Map的创建与merge
Spring IOC 容器源码分析
BUG-NoClassDefFoundError: org/springframework/boot/actuate/trace/WebRequestTraceFilter$CustomStatusResponseWrapper
B-Tree与B+Tree结构图
mysql中的日志文件binlog、redolog、undolog
springboot内嵌定时任务使用及cron表达式讲解
JAVA中 PDF文件转成TIFF文件的2种方式
记-ItextPDF+freemaker 生成PDF文件---导致服务宕机
Oracle误操作--被提交后的数据回退(闪回)
commons-fileupload实现文件上传
热门文章
Spring 事务管理案例 -----文章写得不错 拿来日后学习使用
针对spring--AOP的理解及例子
为你详解Linux安装GCC方法
governor数据源下拉框出现多个数据源
Oracle with as 用法
如题,properties配置文件在项目中是经常用到的,那么读取properties配置文件的方法有哪些呢?
java.lang.ClassCastException是什么错误?
oracle函数语句解析
什么是LDAP认证?
python进阶
Copyright © 2011-2022 走看看