static void Main(string[] args)
{
string s = GetChineseSpell("周杰伦");
Console.WriteLine(s.ToLower());
Console.ReadKey();
}
static public string GetChineseSpell(string strText)
{
int len = strText.Length;
string myStr = "";
for (int i = ; i < len; i++)
{
    myStr += getSpell(strText.Substring(i, ));
}
return myStr;
} static public string getSpell(string cnChar)
{
byte[] arrCN = Encoding.Default.GetBytes(cnChar);
if (arrCN.Length > )
{
    int area = (short)arrCN[];
    int pos = (short)arrCN[];
    int code = (area << ) + pos;
    int[] areacode = { , , , , , , , , , , , , , , , , , , , , , , , , ,
  };
for (int i = ; i < ; i++)
{
int max = ;
if (i != ) max = areacode[i + ];
if (areacode[i] <= code && code < max)
{
    return Encoding.Default.GetString(new byte[] { (byte)( + i) });
}
}
return "*";
}
else return cnChar;
}

控制台运行结果为:

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 ...

随机推荐

  1. 从ora10g 刷数据到 8I基本操作步骤

    从ora10g 刷数据到 8I基本操作步骤 master :oracle 10g snapshot site: oralce 8i 在oracle 8i 中物化视图称为快照,oracle 8i建快照的 ...

  2. Sumsets(3sum问题,枚举d,c二分a+b)

    Sumsets Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9997   Accepted: 2736 Descripti ...

  3. how to translate the text of push button

    Background:In a project, the need to translate the buttons on the screen, as shown below,the followi ...

  4. 【二进制拆分多重背包】【HDU1059】【Dividing】

    Dividing Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total S ...

  5. ASP.NET打印EXCEl报表技术总结

    序言:我们在做企业项目或者一些管理系统的时候往往会用到导出到excel报表这项功能,下面我介绍的是用windows自带的excel来打印 首先必须引入:Interop.Excel.dll.Intero ...

  6. 前端自动化学习笔记(一)——Yeoman,bower,Grunt的安装

    最近看视频学习了前端自动化的一些知识,确实让我大开眼界.感觉前端越来越神器了.同时跟着视频自己也尝试运用了一些工具去构建前端项目,但是中间遇见了很多坑,磕磕绊绊的才实现了一点功能,所以打算记录一下学习 ...

  7. JQuery EasyUI combobox动态添加option

    <input class="easyui-combobox" id="rwlb" name="rwlb" style="wi ...

  8. HDU 1017 - A Mathematical Curiosity

    题目简单,格式酸爽.. #include <iostream> using namespace std; int ans,n,m,p; int main() { cin>>p; ...

  9. Char型和string型字符串比较整理

    1.赋值 char赋值: char ch1[] = "give me"; char ch2[] = "a cup"; strcpy(ch1,ch2); cout ...

  10. 启动程序的c++方法

    #include <Windows.h> void main() { WinExec( "notepad.exe fitdata.txt", SW_SHOW ); // ...