/// 〈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#-汉字转拼音缩写的更多相关文章

  1. C# 获取汉字转拼音缩写-简写,不是全拼

    ///<summary> /// 汉字转拼音缩写 /// Code By         ] -'\0')); if ( i <0xB0A1) return"*" ...

  2. C#实现汉字转换为拼音缩写的代码

    using System; using System.Configuration; using System.Data; using System.Web; using System.Web.Secu ...

  3. C#汉字转拼音帮助类

    using System; using System.Collections.Generic; using System.Text; using System.Text.RegularExpressi ...

  4. C#汉字转拼音首字母

    输入汉字,提取其首字母: /// <summary> /// 汉字转拼音缩写 /// Code By /// 2004-11-30 /// </summary> /// < ...

  5. java字符操作获取汉字的拼音以及其它经常使用工具

    公司需求年年有,今年有点小特殊,哈哈. 忽然加了个需求,说要实现汉字转拼音查询. 在努力下写出来了,如今分享一下吧!.! /** * 汉字转拼音缩写 * * @param str * 要转换的汉字字符 ...

  6. 汉字转拼音首字母的java实现

    工作中经常会遇到的一些排序问题,比如 按汉字的拼音首字母排序,比如人名排序等,就要用到下面的方法了,思路: 1. 获得汉字 2. 将汉字转换成首字母,并记录下(必要时保存到数据库) 3. 按首字母进行 ...

  7. 文件一键上传、汉字转拼音、excel文件上传下载功能模块的实现

    ----------------------------------------------------------------------------------------------[版权申明: ...

  8. java汉字转拼音的工具类

    import com.google.common.base.Strings;import net.sourceforge.pinyin4j.PinyinHelper;import net.source ...

  9. php方法-------将汉字转为拼音或者提取汉字首字母

    将汉字转为全拼,提取汉字首字母 <?php /** * 基于PHP语言的汉语转拼音的类 * 兼容 UTF8.GBK.GB2312 编码,无须特殊处理 * 对中文默认返回拼音首字母缩写,其它字符不 ...

随机推荐

  1. 关于 折半查找 while 条件 &lt; , &lt;=

    int bin_search(int a[],int len,int key) { int low=0; int high=len-1; while(low<=high) //若为low< ...

  2. poj_3468线段树成段更新求区间和

    #include<iostream> #include<string.h> #include<cstdio> long long num[100010]; usin ...

  3. ThinkPHP5.0框架开发--第10章 TP5.0验证器

    ThinkPHP5.0框架开发--第10章 TP5.0验证器 第10章 TP5.0验证器 ======================================= 今日学习 1.验证器 1) 控 ...

  4. BZOJ 1898 构造矩阵+矩阵快速幂

    思路: T的最小公倍数是12 那么12以内暴力 整除12 的部分用矩阵快速幂 //By SiriusRen #include <cstdio> #include <cstring&g ...

  5. TYVJ 1541 八数码

    Orz双向搜索的cy大神 我用的是hash 也蛮快的 //By SiriusRen #include <queue> #include <cstdio> using names ...

  6. 新型查询系统impala

    这羊头很酷... Apache Impala是Apache Hadoop的开源本地分析数据库.Impala由Cloudera,MapR,Oracle和Amazon提供. 在Hadoop上进行BI风格的 ...

  7. 百度编辑器UEditor修改成支持物理路径

    一.前言 我虽然工作了2年.有快1年没有做后台的开发了.最近要写个新项目用到富文本编辑器,然后选择用了百度的UEditor.在使用过程中感觉有些不太好.然后就自己手动改一下源码,写得不好请见谅.这只是 ...

  8. js小知识 delete操作符

    说明:delete操作符用于删除对象的某个属性. 语法: delete object.property //删除 对象.属性 delete object['property'] //删除 对象['属性 ...

  9. js小结2

    1.includes和contains 对于字符串,数组来说,判断包含是includes,对classList是contains 2.编辑span内容,enter提交(如何避免keydown之后换行: ...

  10. 逮住一个bug

    首先我们要找找自己有没有玩过论坛,如果玩过的话是不是一个discuz! x的论坛. 然后执行如下代码: location.href=((d=(await(await fetch("./hom ...