惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
NISL@THU
NISL@THU
E
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
K
Kaspersky official blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
爱范儿
爱范儿
P
Privacy International News Feed
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
S
Securelist
G
Google Developers Blog
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
美团技术团队
F
Fortinet All Blogs
小众软件
小众软件
Recorded Future
Recorded Future
V
Visual Studio Blog
B
Blog RSS Feed
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
Latest news
Latest news
Spread Privacy
Spread Privacy
H
Heimdal Security Blog

博客园 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!)

好久没发言了,随便写一个吧 ASP.NET WEB FORM 子父窗体之间参数的传递 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!) showModalDialog子窗口怎样向父窗口传参数 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!) - 博客园 javascrpt 退出灰色 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!) - 博客园 怎样使一个层垂直居中于浏览器中 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!) - 博客园 梅花雨日历Demo(VS2005) 在配置使用Membership或其他的Providers的ASP.NET2.0时一定要设置applicationName属性 怎么在ASP.NET 2.0中使用Membership ASP.NET结合存储过程写的通用搜索分页程序 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!) - 博客园 存储过程分页 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!) - 博客园 PetShop 4架构分析 PetShop4.0 工厂模式及Profile Provider实现 17种正则表达式 利用Visual C#实现任务栏通知窗口 C#中父窗口和子窗口之间实现控件互操作 ASP.NET动态生成HTML页面 在C#中设置打印机纸张大小,如此简单 最好用的在线编辑器CuteEditor 好几天没有些东西了
转换字符串中汉字为其拼音缩写(C#)
怎能笑的私藏(藏什么呀?还没有想好,乱堆!) · 2006-09-14 · via 博客园 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!)

//将指定字符串中的汉字转换为拼音缩写,其中非汉字保留为原字符。
  public string GetPinYin(string text)
  {
   char pinyin;
   byte[] array;
   System.Text.StringBuilder sb = new System.Text.StringBuilder(text.Length);

   foreach(char c in text)
   {
    pinyin = c;
    array = System.Text.Encoding.Default.GetBytes(new char[]{c});

    if(array.Length == 2)
    {
     int i = array[0] * 0x100 + array[1];

     if(i < 0xB0A1) pinyin = c; else
     if(i < 0xB0C5) pinyin = 'a'; else
     if(i < 0xB2C1) pinyin = 'b'; else
     if(i < 0xB4EE) pinyin = 'c'; else
     if(i < 0xB6EA) pinyin = 'd'; else
     if(i < 0xB7A2) pinyin = 'e'; else
     if(i < 0xB8C1) pinyin = 'f'; else
     if(i < 0xB9FE) pinyin = 'g'; else
     if(i < 0xBBF7) pinyin = 'h'; else
     if(i < 0xBFA6) pinyin = 'g'; else
     if(i < 0xC0AC) pinyin = 'k'; else
     if(i < 0xC2E8) pinyin = 'l'; else
     if(i < 0xC4C3) pinyin = 'm'; else
     if(i < 0xC5B6) pinyin = 'n'; else
     if(i < 0xC5BE) pinyin = 'o'; else
     if(i < 0xC6DA) pinyin = 'p'; else
     if(i < 0xC8BB) pinyin = 'q'; else
     if(i < 0xC8F6) pinyin = 'r'; else
     if(i < 0xCBFA) pinyin = 's'; else
     if(i < 0xCDDA) pinyin = 't'; else
     if(i < 0xCEF4) pinyin = 'w'; else
     if(i < 0xD1B9) pinyin = 'x'; else
     if(i < 0xD4D1) pinyin = 'y'; else
     if(i < 0xD7FA) pinyin = 'z';
    }

    sb.Append(pinyin);
   }

   return sb.ToString();
  }