输入汉字,提取其首字母:

        /// <summary>

        /// 汉字转拼音缩写

        /// Code By 

        /// 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 /// 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. (转载)delphi中获取汉字的拼音首字母

    delphi中获取汉字的拼音首字母1.py: array[216..247] of string = ({216}'CJWGNSPGCGNESYPB' + 'TYYZDXYKYGTDJNMJ' + ' ...

  2. SqlServer 汉字转换拼音首字母函数

    CREATE function [dbo].[Func_GetPY](@str nvarchar(4000))returns nvarchar(4000)asbegin set @str=RTRIM( ...

  3. 简单测试--C#实现中文汉字转拼音首字母

    第一种: 这个是自己写的比较简单的实现方法,要做汉字转拼音首字母,首先应该有一个存储首字母的数组,然后将要转拼音码的汉字与每个首字母开头的第一个汉字即“最小”的汉字作比较,这里的最小指的是按拼音规则比 ...

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

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

  5. sql获取汉字的拼音首字母的函数

    ql获取汉字的拼音首字母   if exists (select * from sysobjects where id = object_id(N'[fn_ChineseToSpell]') and ...

  6. C#获取包括一二级汉字的拼音 首字母

    C#获取包括一二级汉字的拼音 首字母 声母 汉字拼音转换 using System; using System.Collections.Generic; using System.Linq; usin ...

  7. js汉字转拼音首字母

    js汉字转拼音首字母 2018-04-09 阅读 1018 收藏 1 原链:segmentfault.com 分享到:   前端必备图书<JavaScript设计模式与开发实践> > ...

  8. C# 获取汉字的拼音首字母和全拼(含源码)

    C# 获取汉字的拼音首字母 一种是把所有中文字符集合起来组成一个对照表:另一种是依照汉字在Unicode编码表中的排序来确定拼音的首字母.碰到多音字时就以常用的为准(第一种方法中可以自行更改,方法为手 ...

  9. 获取汉字的拼音首字母--pinyin

    var pinyin = (function (){ var Pinyin = function (ops){ this.initialize(ops); }, options = { checkPo ...

  10. mysql数据库中查询汉字的拼音首字母

    本人提供的方法有如下特点: 1.代码精简,使用简单,只要会基本的SQL语句就行2.不用建立mysql 函数等复杂的东西3.汉字库最全,可查询20902个汉字 方法如下: 1.建立拼音首字母资料表Sql ...

随机推荐

  1. MCI音乐播放

    缘由: 在改正俄罗斯方块程序的功能的时候,想给这个程序增加一个背景音乐.本想用PlayWave来做的,但想到这个功能十分常用,那还不如封装一个自己的CMusic 类,以备不时之需.本来以为很容易的,可 ...

  2. 【转】Android学习系列(1)--为App签名(为apk签名)

    原文网址:http://www.cnblogs.com/qianxudetianxia/archive/2011/04/09/2010468.html 写博客是一种快乐,前提是你有所写,与人分享,是另 ...

  3. 负载均衡服务器session共享的解决方案

    在ASP.NET的程序中要使用Session对象时,必须确保页面的@page指令中EnableSessionState属性是True或者Readonly,并且在web.config文件中正确的设置了S ...

  4. bugfree如何修改Bug7种解决方案的标注方法

    Bug有7种解决方案的标注方法 By Design- 就是这么设计的,无效的Bug Duplicate - 这个问题别人已经发现了,重复的Bug External - 是个外部因素(比如浏览器.操作系 ...

  5. POJ 2449

    #include<queue> #include<cstdio> #include<string> #include<cstring> #include ...

  6. 跟我学机器视觉-HALCON学习例程中文详解-测量圆环脚宽间距

    跟我学机器视觉-HALCON学习例程中文详解-测量圆环脚宽间距 This example program demonstrates the basic usage of a circular meas ...

  7. nodejs调试工具node-inspector入门随笔

    最近打算玩玩node. 众所周知,在前端,调试代码有一众天然好工具——浏览器!特别是 chrome,使得 jser 们如鱼得水,玩得风生水起.但是到了node,情况就不一样了,js 代码不再运行在单纯 ...

  8. NOIP 2015 子串

    借鉴大神思路... #include<cstdio> #include<cstring> #include<cstdlib> #include<iostrea ...

  9. codeforces 660C Hard Process

    维护一个左右区间指针就可以. #include<cstdio> #include<cstring> #include<iostream> #include<q ...

  10. jsp简易文件上传(common.fileupload)

    昨天开始重新架构我的V&View(维视),之前写文章使用的是一个kindediter的插件,挺好用的.最近不知道咋了,出现了些小问题.早在写V&View的时候就想用以下两种方法实现文章 ...