C#-汉字转拼音缩写
/// 〈summary〉
/// 汉字转拼音缩写
/// Code By MuseStudio@hotmail.com
/// 2004-11-30
/// 〈/summary〉
/// 〈param name="str"〉要转换的汉字字符串〈/param〉
/// 〈returns〉拼音缩写〈/returns〉
public string GetPYString(string str)
{
string tempStr = "";
foreach(char c in str)
{
if((int)c 〉= && (int)c 〈=)
{//字母和符号原样保留
tempStr += c.ToString();;
}
else
{//累加拼音声母
tempStr += GetPYChar(c.ToString());;
}
}
return tempStr;;
} /// 〈summary〉
/// /// Code By MuseStudio@hotmail.com
/// 2004-11-30
/// 〈/summary〉
/// 〈param name="c"〉要转换的单个汉字〈/param〉
/// 〈returns〉拼音声母〈/returns〉
public string GetPYChar(string c)
{
byte[] array = new byte[];
array = System.Text.Encoding.Default.GetBytes(c);
int i = (short)(array[] - '\0') * + ((short)(array[] - '\0'));
if ( i 〈 0xB0A1) return "*";
if ( i 〈 0xB0C5) return "a";
if ( i 〈 0xB2C1) return "b";
if ( i 〈 0xB4EE) return "c";
if ( i 〈 0xB6EA) return "d";
if ( i 〈 0xB7A2) return "e";
if ( i 〈 0xB8C1) return "f";
if ( i 〈 0xB9FE) return "g";
if ( i 〈 0xBBF7) return "h";
if ( i 〈 0xBFA6) return "g";
if ( i 〈 0xC0AC) return "k";
if ( i 〈 0xC2E8) return "l";
if ( i 〈 0xC4C3) return "m";
if ( i 〈 0xC5B6) return "n";
if ( i 〈 0xC5BE) return "o";
if ( i 〈 0xC6DA) return "p";
if ( i 〈 0xC8BB) return "q";
if ( i 〈 0xC8F6) return "r";
if ( i 〈 0xCBFA) return "s";
if ( i 〈 0xCDDA) return "t";
if ( i 〈 0xCEF4) return "w";
if ( i 〈 0xD1B9) return "x";
if ( i 〈 0xD4D1) return "y";
if ( i 〈 0xD7FA) return "z";
return "*";;
}
C#-汉字转拼音缩写的更多相关文章
- C# 获取汉字转拼音缩写-简写,不是全拼
///<summary> /// 汉字转拼音缩写 /// Code By ] -'\0')); if ( i <0xB0A1) return"*" ...
- C#实现汉字转换为拼音缩写的代码
using System; using System.Configuration; using System.Data; using System.Web; using System.Web.Secu ...
- C#汉字转拼音帮助类
using System; using System.Collections.Generic; using System.Text; using System.Text.RegularExpressi ...
- C#汉字转拼音首字母
输入汉字,提取其首字母: /// <summary> /// 汉字转拼音缩写 /// Code By /// 2004-11-30 /// </summary> /// < ...
- java字符操作获取汉字的拼音以及其它经常使用工具
公司需求年年有,今年有点小特殊,哈哈. 忽然加了个需求,说要实现汉字转拼音查询. 在努力下写出来了,如今分享一下吧!.! /** * 汉字转拼音缩写 * * @param str * 要转换的汉字字符 ...
- 汉字转拼音首字母的java实现
工作中经常会遇到的一些排序问题,比如 按汉字的拼音首字母排序,比如人名排序等,就要用到下面的方法了,思路: 1. 获得汉字 2. 将汉字转换成首字母,并记录下(必要时保存到数据库) 3. 按首字母进行 ...
- 文件一键上传、汉字转拼音、excel文件上传下载功能模块的实现
----------------------------------------------------------------------------------------------[版权申明: ...
- java汉字转拼音的工具类
import com.google.common.base.Strings;import net.sourceforge.pinyin4j.PinyinHelper;import net.source ...
- php方法-------将汉字转为拼音或者提取汉字首字母
将汉字转为全拼,提取汉字首字母 <?php /** * 基于PHP语言的汉语转拼音的类 * 兼容 UTF8.GBK.GB2312 编码,无须特殊处理 * 对中文默认返回拼音首字母缩写,其它字符不 ...
随机推荐
- hdu4390-Number Sequence(容斥计算)
题意:给定b数列.计算有多少种数列 a1,a2,...,an 满足条件 a1*a2*...*an=b1*b2*-*bn (ai>1). 解法:处理出b数列中出现的全部质因子的数量记录在map中, ...
- node13---node使用mongodb
01.js /** *最先的后台语言是Asp(微软的), */ var express = require("express"); //数据库引用 var MongoClient ...
- nyoj--214--单调递增子序列(二)(二分查找+LIS)
单调递增子序列(二) 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 给定一整型数列{a1,a2...,an}(0<n<=100000),找出单调递增最长子序 ...
- ORA-01950: 表空间'USERS'中无权限的2种解决办法
在创建了一个新的表空间和一个新的用户,当用这个新用户创建表时, 却出现:ORA-01950: 表空 间'USERS'中无权限. 我已经把创建表的权限赋给了此用户,怎么还会缺少权限呢?解决办法 ...
- [jzoj 6084] [GDOI2019模拟2019.3.25] 礼物 [luogu 4916] 魔力环 解题报告(莫比乌斯反演+生成函数)
题目链接: https://jzoj.net/senior/#main/show/6084 https://www.luogu.org/problemnew/show/P4916 题目: 题解: 注: ...
- oracle锁表进行关闭
--查询被锁表 select 'alter system kill session '''||sess.sid||','||sess.serial#||''';', sess.sid, sess.se ...
- IOS系统设置页面跳转
目录: 跳转 iOS10- 版本跳转url转 iOS10+ 版本跳转url转 跳转符 跳转到系统设置界面代码: // 自己应用的设置界面:url = UIApplicationOpenSettings ...
- C++之易混淆知识点二
1.数据抽象与封装 数据抽象是一种接口和实现相分离的编程技术,设计者关心的是如何实现这些接口,而使用者仅仅知道这些接口,抽象地考虑这些接口做什么的就可以了,不必去考虑如何实现这一层次. 封装是将低层次 ...
- 视图层 view
视图层是 Django 处理请求的核心代码层,我们大多数 Python 代码都集中在这一层面.它对外接收用户请求,对内调度模型层和模版层,统合数据库和前端,最后根据业务逻辑,将处理好的数据,与前端结合 ...
- 多任务-进程之进程池Pool
1.什么是池? 首先从字面上看,池代表着一个容器,用来承载着某些内容的容器,了解到这里,就对进程池有了一个初步的轮廓. 2.什么是进程池Pool? (1)利用现实中的事物来理解: 对于小白初学者,接触 ...