用C#将汉字转为以字母开头的方法
来源:互联网 发布:seo pdf 编辑:程序博客网 时间:2024/05/14 12:10
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public partial class test : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { Response.Write(GetPYString("没有共产党就没有新中国")); } public string GetPYString(string str) { string tempStr = ""; foreach (char c in str) { if ((int)c >= 33 && (int)c <= 126) { tempStr += c.ToString(); } else { tempStr += GetPYChar(c.ToString()); } } return tempStr; } public string GetPYChar(string c) { byte[] array = new byte[2]; array = System.Text.Encoding.Default.GetBytes(c); int i = (short)(array[0] - '\0') * 256 + ((short)(array[1] - '\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 "J"; 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 "*"; }}
输出结果为:MYGCDJMYXZG
- 用C#将汉字转为以字母开头的方法
- js正则校验只能以字母和汉字开头的input输入
- iOS 判断字符串是否以字母或者汉字开头
- 关于mysql 查询 按汉字的首字母进行排序和查找某个以某字母开头的谋汉字
- 以首字母开头的所有汉字组合
- 验证用户输入的字符串中时候只含有数字,字母或汉字.总长度为6~~20,并且以字母,汉字开头
- sql 根据字母获取以字母开头的数据
- java小算法—将阿拉伯字母转为汉字
- C#将数字转正字母的方法
- C#将字母或数字加密成字母的方法
- 共享 将汉字转为拼音的类
- 查看PHP以字母"E"开头的常量
- mysql 过滤查询(以字母开头,以数字开头,非数字开头,非字母开头)
- 将汉字转为拼音
- 将汉字转为字符串
- Python将'\u'开头的字符串转为unicode编码
- Struts2 action中不要将方法以get开头!!!
- 关于Python中以字母r/R,或字母u/U 开头的字符串
- objective-C 的内存管理之-引用计数
- INF Version Section详解
- Activity 、Intent深入解析
- 命名管道在WIN7下运行出错的解决方法
- 偶编写的软件 彻底删除文件(File Delete Absolutely) 1.03 已发布在国内6大软件下载网站,新增功能简介
- 用C#将汉字转为以字母开头的方法
- GXT之旅:第八章:Portal&Drag-Drop——项目使用Drag-Drop重构(1)
- Java读取Properties文件的六种方法
- JS常用代码笔记
- j今天
- UDP/IP 阻塞模式与非阻塞模式
- a 和&a 的区别
- 计算机网络 以太网 和令牌环网
- 简洁的数据结构