zoukankan
html css js c++ java
奇怪的代码,好像没有什么场合用得着。
C#汉字转拼音
1
/**/
///
<summary>
2
///
汉字转拼音缩写
3
///
Code By MuseStudio@hotmail.com
4
///
2004-11-30
5
///
</summary>
6
///
<param name="str">
要转换的汉字字符串
</param>
7
///
<returns>
拼音缩写
</returns>
8
public
string
GetPYString(
string
str)
9
{
10
string
tempStr
=
""
;
11
foreach
(
char
c
in
str)
12
{
13
if
((
int
)c
>=
33
&&
(
int
)c
<=
126
)
14
{
//
字母和符号原样保留
15
tempStr
+=
c.ToString();
16
}
17
else
18
{
//
累加拼音声母
19
tempStr
+=
GetPYChar(c.ToString());
20
}
21
}
22
return
tempStr;
23
}
24
25
/**/
///
<summary>
26
///
取单个字符的拼音声母
27
///
Code By MuseStudio@hotmail.com
28
///
2004-11-30
29
///
</summary>
30
///
<param name="c">
要转换的单个汉字
</param>
31
///
<returns>
拼音声母
</returns>
32
public
string
GetPYChar(
string
c)
33
{
34
byte
[] array
=
new
byte
[
2
];
35
array
=
System.Text.Encoding.Default.GetBytes(c);
36
int
i
=
(
short
)(array[
0
]
-
'
\0
'
)
*
256
+
((
short
)(array[
1
]
-
'
\0
'
));
37
38
if
( i
<
0xB0A1
)
return
"
*
"
;
39
if
( i
<
0xB0C5
)
return
"
a
"
;
40
if
( i
<
0xB2C1
)
return
"
b
"
;
41
if
( i
<
0xB4EE
)
return
"
c
"
;
42
if
( i
<
0xB6EA
)
return
"
d
"
;
43
if
( i
<
0xB7A2
)
return
"
e
"
;
44
if
( i
<
0xB8C1
)
return
"
f
"
;
45
if
( i
<
0xB9FE
)
return
"
g
"
;
46
if
( i
<
0xBBF7
)
return
"
h
"
;
47
if
( i
<
0xBFA6
)
return
"
g
"
;
48
if
( i
<
0xC0AC
)
return
"
k
"
;
49
if
( i
<
0xC2E8
)
return
"
l
"
;
50
if
( i
<
0xC4C3
)
return
"
m
"
;
51
if
( i
<
0xC5B6
)
return
"
n
"
;
52
if
( i
<
0xC5BE
)
return
"
o
"
;
53
if
( i
<
0xC6DA
)
return
"
p
"
;
54
if
( i
<
0xC8BB
)
return
"
q
"
;
55
if
( i
<
0xC8F6
)
return
"
r
"
;
56
if
( i
<
0xCBFA
)
return
"
s
"
;
57
if
( i
<
0xCDDA
)
return
"
t
"
;
58
if
( i
<
0xCEF4
)
return
"
w
"
;
59
if
( i
<
0xD1B9
)
return
"
x
"
;
60
if
( i
<
0xD4D1
)
return
"
y
"
;
61
if
( i
<
0xD7FA
)
return
"
z
"
;
62
63
return
"
*
"
;
64
}
65
66
http://kwklover.cnblogs.com/archive/2006/01/12/316308.html
查看全文
相关阅读:
在LINQTOSQL中实现“级联删除”的方法
“BindingNavigator”如何在删除前弹出确认框?
OOP设计思考——究竟是继承自普通类,还是继承自抽象类?
ASP.NET控件为什么无法使用结构?
如何消除Web自定义控件的“自生成”复合属性的冗余类名称?
用C#动态输出js单引号问题
关于ready和load方法作用于不同情况下的比较
关于CodeSign error : Certificate identity 'iPhone Distribution *** : ...问题
[iOS]Xcode4/iOS5调试UncaughtException崩溃First throw call stack不打印方法名的解决方案
Lion版本Mac OS下查看iPhone Simulator目录
原文地址:https://www.cnblogs.com/LCX/p/387797.html
最新文章
js变量共享
jQuery的live绑定事件在mobile safari(iphone / ipad / ipod)上失效的解决方案
Js控制flash的操作
HTML Flash Object属性
FlashObject详解:Flash的检测和嵌入Javascript脚本
Flash与页面交互的钥匙之 AllowScriptAccess
如何解锁图层
PostgreSQL remote connection
[转载] 程序员喝酒喝出的计算机文化
热烈庆祝Vsignsoft's Blog胜利开通暨五一国际劳动节
热门文章
成功实现与XServe的RPC通讯
Set Stargate IP
[转载] 与IT同仁们共勉
Icon resource base
Solve to open *.chm file failed For WinXP English Edition
[转载] 爱的终点
Postgres使用小结安装
几个常见的定时器
探索.NET中事件机制(续)——虚事件和事件重写问题,微软的Bug?!
OOP设计思考——何时使用接口?
Copyright © 2011-2022 走看看