国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

獲得漢字字符串的首個(gè)拼音字母的縮寫(xiě)

2019-11-18 16:54:16
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
    標(biāo)題可能不太清楚,實(shí)現(xiàn)的功能如下:我愛(ài)中國(guó)-WAZG
 1。漢字字符與英文字母之間區(qū)別
     標(biāo)準(zhǔn)的asc表不包含漢字字符,因?yàn)橐粋€(gè)asc字符只有1byte,就是8bit,8bit所能代表的數(shù)字范圍,如果是有符號(hào)的好,因該為-128-127,無(wú)符號(hào)的話,應(yīng)該為0-255。而我們知道,一個(gè)漢字字符,應(yīng)該占有2個(gè)byte,表示范圍應(yīng)該為-32768-32767,所以漢字的asc,舉例一段bit:  11002111,11111101它所代表的字符,應(yīng)該超過(guò)了asc所能表述的范圍,這時(shí)候就會(huì)產(chǎn)生溢出。所以占有兩個(gè)byte的漢字字符的asc碼應(yīng)該為負(fù)的。
2.功能實(shí)現(xiàn)
  1using System;
  2using System.Collections.Generic;
  3using System.Text;
  4
  5namespace Consoleapplication1
  6{
  7    class PRogram
  8    {
  9        static void Main(string[] args)
 10        {
 11            Console.WriteLine(GetChineseFirstChar("我a*%愛(ài)你中國(guó)"));;
 12        }
 13        static string GetChineseFirstChar(string chineseStr)
 14        {
 15            StringBuilder sb = new StringBuilder();
 16            int length = chineseStr.Length;
 17            for (int i = 0; i < length; i++)
 18            {            
 19                char chineseChar = chineseStr[i];
 20                sb.Append(GetpyChar(chineseChar));
 21            }
 22            return sb.ToString();
 23        }
 24        static string GetpyChar(char c)
 25        {
 26            int ascCode = Microsoft.VisualBasic.Strings.Asc(c);
 27            int temp = 65536 + ascCode;
 28            if (temp >= 45217 && temp <= 45252)
 29            {
 30                return "A";
 31            }
 32            else if (temp >= 45253 && temp <= 45760)
 33            {
 34                return "B";
 35            }
 36            else if (temp >= 45761 && temp <= 46317)
 37            {
 38                return "C";
 39            }
 40            else if (temp >= 46318 && temp <= 46825)
 41            {
 42                return "D";
 43            }
 44
 45
 46            else if (temp >= 46826 && temp <= 47009)
 47            {
 48                return "E";
 49            }
 50            else if (temp >= 47010 && temp <= 47296)
 51            {
 52                return "F";
 53            }
 54            else if (temp >= 47297 && temp <= 47613)
 55            {
 56                return "G";
 57            }
 58            else if (temp >= 47614 && temp <= 48118)
 59            {
 60                return "H";
 61            }
 62            else if (temp >= 48119 && temp <= 49061)
 63            {
 64                return "J";
 65            }
 66            else if (temp >= 49062 && temp <= 49323)
 67            {
 68                return "K";
 69            }
 70            else if (temp >= 49324 && temp <= 49895)
 71            {
 72                return "L";
 73            }
 74            else if (temp >= 49896 && temp <= 50370)
 75            {
 76                return "M";
 77            }
 78            else if (temp >= 50371 && temp <= 50613)
 79            {
 80                return "N";
 81            }
 82            else if (temp >= 50614 && temp <= 50621)
 83            {
 84                return "O";
 85            }
 86            else if (temp >= 50622 && temp <= 50905)
 87            {
 88                return "P";
 89            }
 90            else if (temp >= 50906 && temp <= 51386)
 91            {
 92                return "Q";
 93            }
 94            else if (temp >= 51387 && temp <= 51445)
 95            {
 96                return "R";
 97            }
 98            else if (temp >= 51446 && temp <= 52217)
 99            {
100                return "S";
101            }
102            else if (temp >= 52218 && temp <= 52697)
103            {
104                return "T";
105            }
106            else if (temp >= 52698 && temp <= 52979)
107            {
108                return "W";
109            }
110            else if (temp >= 52980 && temp <= 53688)
111            {
112                return "X";
113            }
114            else if (temp >= 53689 && temp <= 54480)
115            {
116                return "Y";
117            }
118            else if (temp >= 54481 && temp <= 62289)
119            {
120                return "Z";
121            }
122            else
123            {
124                return c.ToString();
125            }
126        }
127    }
128}
129
http://www.survivalescaperooms.com/jillzhang/archive/2006/10/30/544596.html
發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 武胜县| 阳东县| 平邑县| 天全县| 沾益县| 赤水市| 潞西市| 木兰县| 沁源县| 芒康县| 乌海市| 乳源| 平远县| 辽宁省| 平顶山市| 高碑店市| 偃师市| 东方市| 永登县| 息烽县| 徐水县| 阜新| 阿合奇县| 恭城| 高州市| 巧家县| 镇雄县| 长兴县| 霍林郭勒市| 潜江市| 土默特左旗| 凉城县| 恭城| 沂水县| 南溪县| 高清| 辽阳市| 大余县| 莱阳市| 通许县| 呼和浩特市|