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

首頁 > 開發 > 綜合 > 正文

獲得漢字字符串的首個拼音字母的縮寫

2024-07-21 02:28:31
字體:
來源:轉載
供稿:網友
    標題可能不太清楚,實現的功能如下:我愛中國-wazg
 1。漢字字符與英文字母之間區別
     標準的asc表不包含漢字字符,因為一個asc字符只有1byte,就是8bit,8bit所能代表的數字范圍,如果是有符號的好,因該為-128-127,無符號的話,應該為0-255。而我們知道,一個漢字字符,應該占有2個byte,表示范圍應該為-32768-32767,所以漢字的asc,舉例一段bit:  11002111,11111101它所代表的字符,應該超過了asc所能表述的范圍,這時候就會產生溢出。所以占有兩個byte的漢字字符的asc碼應該為負的。
2.功能實現
  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*%愛你中國"));;
 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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 隆林| 平江县| 汤原县| 岱山县| 清水河县| 鄂州市| 峨山| 梅河口市| 贺州市| 深水埗区| 乐东| 仲巴县| 贡嘎县| 洛南县| 南雄市| 北京市| 昭苏县| 遵义市| 高淳县| 炉霍县| 安吉县| 鸡泽县| 开封市| 石泉县| 巴楚县| 宁阳县| 洪雅县| 台江县| 马山县| 石渠县| 金寨县| 乌什县| 莱西市| 滨海县| 措勤县| 西盟| 宁陕县| 盐池县| 奉新县| 清丰县| 大新县|