Procedure for Chinese characters in ASP.NET

xiaoxiao2021-03-06  58

This is its HTML source code <% @ page language = "c #" codebehind = "no1.aspx.cs" autoeventwireup = "false" inherits = "WebApplication2.no1"%> NO1 </ title> <meta content =" Microsoft Visual Studio .NET 7.1 "Name =" Generator "> <meta content =" c # "Name = "CODE_LANGUAGE"> <meta content = "javascript" name = "vs_defaultClientScript"> <meta content = "http://schemas.microsoft.com/intellisense/ie5"; name = "vs_targetSchema"> </ HEAD> <body MS_Positioning = "gridLayout"> <form id = "form1" method = "post" runat = "server"> <font face = "Song body"> <asp: textbox id = "TextBox1" style = "z-index: 101; LEFT: 32PX; Position: Absolute; Top: 24px "Runat =" Server "> </ asp: textbox> <ask: button id =" button1 "style =" z-index: 102; Left: 200px; Position: absolute; Top: 24px "Runat =" server "text =" button "> </ ask: button> <ask: label id =" Label1 "style =" z-index: 103; Left: 40px; position: absolute; top: 72px "Runat =" server "> </ asp: label> </ font> </ form> </ body> </ html> This is its CS source Sequence: using System; using System.Text; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.ui.WebControls; use system.web.ui.htmlcontrols;</p> <p>A summary description of Namespace WebApplication2 {/// <summary> /// NO1.</p> <p>/// </ summary> public class No1: System.Web.UI.Page {protected System.Web.UI.WebControls.TextBox TextBox1; protected System.Web.UI.WebControls.Button Button1; protected System.Web.UI. WebControls.Label Label1; Private HashTable Ht; String G (INT NUM) {IF (Num <-20319 || NUM> -10247) Return ""; While (! Ht.containskey (num)) Num--; returni Num] .tostring ();} string c (string hz) {byte [] b = system.text.Encoding.default.getBytes (hz); int P; stringbuilder return = new stringbuilder (); for (int i = 0 i <b.Length; i ) {p = (int) B [i]; if (p> 160) {p = p * 256 b [ i] -65536; RET.APPpend (g (p) } Else {ret.Append ((char) p);}} return ret.toString (); void b () {ht = new hashtable (); ht.add (-20319, "a"); HT .Add (-20317, "ai"); ht.add (-20304, "an"); ht.add (-20295, "ang"); ht.add (-20292, "ao"); ht.add (-20283, "ba"); ht.add (-20265, "bai"); ht.add (-20257, "ban"); ht.add (-20242, "bang"); ht.add (- 20230, "bao"); ht.add (-20051, "bei"); ht.add (-20 036, "BEN"); ht.add (-20032, "beng"); ht.add (-20026, "bi"); HT.Add (-20002, "bian"); ht.add (-19990, "BIAO"); HT.Add (-19986, "Bie"); HT.Add (-19982, "bin"); ht.add (-19976, "bing"); ht.add (-19805, "bo "); HT.Add (-19784," bu "); HT.Add (-19775," CA "); HT.Add (-19774," cai "); ht.add (-19763," can ") ht.add (-19756, "can"); HT.Add (-19751, "CAO"); HT.Add (-19746, "CE"); ht.add (-19741, "keng"); HT .Add (-19739, "cha"); HT.Add (-19728, "chai");</p> <p>HT.Add (-19725, "CHAN"); HT.Add (-19715, "Chang"); HT.Add (-19540, "chao"); HT.Add (-19531, "CHE"); HT. Add (-19525, "chen"); ht.add (-19515, "Cheng"); HT.Add (-19500, "chi"); HT.Add (-19484, "chong"); ht.add ( -19479, "Chou"); HT.Add (-19467, "chu"); HT.Add (-19289, "chuai"); HT.Add (-19288, "chuan"); ht.add (-19281 "chuang"); HT.Add (-19275, "chui"); HT.Add (-19270, "chun"); HT.Add (-19263, "chuo"); ht.add (-19261, " Ci "); HT.Add (-19249," cong "); ht.add (-19243," cou "); ht.add (-19242," cu "); ht.add (-19238," cuan " Ht.Add (-19235, "CUI"); HT.Add (-19227, "CUN"); HT.Add (-19224, "CUO"); HT.Add (-19218, "DA"); HT.Add (-19212, "DAI"); HT.Add (-19038, "DAN"); HT.Add (-19023, "DANG"); HT.Add (-19018, "DAO"); HT. Add (-19006, "de"); ht.add (-19003, "deng"); ht.add (-18996, "di"); ht.add (-18977, "dian"); ht.add ( -18961, "DIAO"); HT.Add (-18952, "DIE"); HT.Add (-18783, "ding"); ht.add (-18774, "diu"); ht.add (-18773 "dong"); ht.add (-18763, "dou"); ht.add (-18756, "du"); HT.Add (-18741, "duan"); ht.add (-18735, " DUI "); ht.add (-187 31, "Dun"); HT.Add (-18722, "duo"); HT.Add (-18710, "e"); ht.add (-18697, "en"); ht.add (-18696, "ER"); HT.Add (-18526, "fa"); ht.add (-18518, "fan"); ht.add (-18501, "fang"); ht.add (-18490, "fei "); HT.Add (-18478," fen "); ht.add (-18463," feng "); HT.Add (-18448," fo "); ht.add (-18447," fou ") Ht.add (-18446, "</p> <p>"); HT.Add (-18239," ga "); HT.Add (-18237," gai "); ht.add (-18231," gan "); ht.add (-18220," gang " Ht.Add (-18211, "gao"); HT.Add (-18201, "GE"); ht.add (-18184, "gei"); ht.add (-18183, "gen"); HT.Add (-18181, "geng"); HT.Add (-18012, "gong"); HT.Add (-17997, "gou"); HT.Add (-17988, "gu"); HT. Add (-17970, "gua"); ht.add (-17964, "guai"); HT.Add (-17961, "guan"); ht.add (-17950, "guang"); ht.add ( -17947, "GUI"); HT.Add (-17931, "gun"); ht.add (-17928, "guo"); HT.Add (-17922, "ha"); ht.add (-17759 "Hai"); ht.add (-17752, "han"); HT.Add (-17733, "hang"); HT.Add (-17730, "hao"); ht.add (-17721, " HT.Add (-17703, "hei"); HT.Add (-17701, "HEN"); ht.add (-17697, "heng"); ht.add (-17692, "hong" Ht.Add (-17683, "hou"); Ht.Add (-17676, "hu"); Ht.Add (-17496, "hua"); ht.add (-17487, "huai"); HT.Add (-17482, "huan"); HT.Add (-17468, "huang"); HT.Add (-17454, "hui"); HT.Add (-17433, "hun"); HT. Add (-17427, "huo"); HT.Add (-17417, "ji"); ht.add (-17202, "jian); ht.add (-17185," jian "); ht.add ( -16983, "jiang"); ht.add (-16970, "jia O "); HT.Add (-16942," jie "); HT.Add (-16915," jin "); ht.add (-16733," jing "); ht.add (-16708," jiong " HT.Add (-16706, "jiu"); HT.Add (-16689, "ju"); HT.Add (-16664, "juan"); ht.add (-16657, "jue"); Ht.Add (-16647, "jun"); HT.Add (-16474, "ka"); HT.Add (-16470, "kai"); HT.Add (-16465, "kan"); HT. Add (-16459, "</p> <p>"); ht.add (-16452," kao "); ht.add (-16448," ke "); HT.Add (-16433," ken "); ht.add (-16429," keng " HT.Add (-16427, "kong"); HT.Add (-16423, "kou"); ht.add (-16419, "ku"); ht.add (-16412, "kua"); Ht.Add (-16407, "kuai"); HT.Add (-16403, "kuan"); HT.Add (-16401, "kuang"); HT.ADD (-16393, "kui"); HT. Add (-16220, "kun"); HT.Add (-16216, "kuo"); HT.Add (-16212, "la"); ht.add (-16205, "lai"); ht.add ( -16202, "LAN"); HT.Add (-16187, "lang"); HT.Add (-16180, "lao"); ht.add (-16171, "le"); ht.add (-16169 "lei"); HT.Add (-16158, "leng"); HT.ADD (-16155, "li"); ht.add (-15959, "lia"); ht.add (-15958, " "); ht.add (-15944," liang "); ht.add (-15933," liao "); ht.add (-15920," lie "); HT.Add (-15915," lin " ); HT.Add (-15903, "ling"); ht.add (-15889, "liu"); ht.add (-15878, "long"); HT.Add (-15707, "lou"); HT.Add (-15701, "lu"); HT.Add (-15681, "lv"); HT.Add (-15667, "luan"); HT.Add (-15661, "lue"); HT. Add (-15659, "lun"); HT.Add (-15652, "luo"); HT.Add (-15640, "mA"); ht.add (-15631, "mai"); ht.add ( -15625, "man"); ht.add (-15454, "mang"); ht.a DD (-15448, "MAO"); HT.Add (-15436, "ME"); HT.Add (-15435, "MEI"); HT.Add (-15419, "MEN"); ht.add ( -15416, "Meng"); HT.Add (-15408, "mi"); HT.Add (-15394, "mian"); ht.add (-15385, "miao"); ht.add (-15377 "MIE"); HT.Add (-15375, "min"); HT.Add (-15369, "ming"); ht.add (-15363, "miu"); ht.add (-15362, " Mo ");</p> <p>HT.Add (-15183, "mou"); HT.Add (-15180, "mu"); HT.Add (-15165, "NA"); HT.Add (-15158, "nai"); HT. Add (-15153, "nan"); ht.add (-15150, "nang"); ht.add (-15149, "nao"); HT.Add (-15144, "ne"); ht.add ( -15143, "Nei"); HT.Add (-15141, "NEN"); HT.Add (-15140, "NENG"); ht.add (-15139, "ni"); ht.add (-15128 "nian"); ht.add (-15121, "niang"); ht.add (-15119, "niao"); ht.add (-15117, "nie"); HT.Add (-15110, " "); HT.Add (-15109," ning "); HT.Add (-14941," niu "); HT.Add (-14937," nong "); ht.add (-14933," nu " Ht.Add (-14930, "nV"); HT.Add (-14929, "nuan"); ht.add (-14928, "nue"); ht.add (-14926, "nuo"); Ht.Add (-14922, "O"); HT.Add (-14921, "OU"); HT.Add (-14914, "PA"); HT.Add (-14908, "PAI"); HT. Add (-14902, "PAN"); HT.Add (-14894, "pang"); HT.Add (-14889, "PAO"); ht.add (-14882, "pei"); ht.add ( -14873, "PEN"); HT.Add (-14871, "peng"); HT.Add (-14857, "pi"); HT.Add (-14678, "pian"); ht.add (-14674 "PIAO"); HT.Add (-14670, "PIE"); HT.Add (-14668, "PIN"); HT.Add (-14663, "ping"); ht.add (-14654, " PO "); HT.Add (-14645," pu "); ht.add (-14630," qi "); ht.add (-14594," qia "); ht.add (-1442 9, "qian"); ht.add (-14407, "qiang"); ht.add (-14399, "qiao"); ht.add (-14384, "qie"); HT.Add (-14379, "qin"); HT.Add (-14368, "qing"); HT.Add (-14355, "qiong"); ht.add (-14353, "qiu"); ht.add (-14345, "qu "); ht.add (-14170," quan "); ht.add (-14159," que "); HT.Add (-14151," qun "); ht.add (-14149," ran ") ;</p> <p>HT.Add (-14145, "rang"); HT.Add (-14140, "RAO"); HT.Add (-14137, "RE"); HT.Add (-14135, "ren"); HT. Add (-14125, "RENG"); HT.Add (-14123, "ri"); ht.add (-14122, "rong"); ht.add (-14112, "rou"); ht.add ( -14109, "RU"); HT.Add (-14099, "Ruan"); HT.Add (-14097, "RUI"); HT.Add (-14094, "run"); ht.add (-14092 "Ruo"); HT.Add (-14090, "sa"); ht.add (-14087, "sai"); HT.Add (-14083, "san"); ht.add (-13917, " "); HT.Add (-13914," SAO "); HT.Add (-13910," SE "); ht.add (-13907," SEN "); ht.add (-13906," send " HT.Add (-13905, "SHA"); HT.Add (-13896, "shai"); ht.add (-13894, "shan"); ht.add (-13878, "shang"); HT.Add (-13870, "shao"); HT.Add (-13859, "she"); HT.Add (-13847, "shen"); HT.Add (-13831, "SHENG"); HT. Add (-13658, "shi"); ht.add (-13611, "shou"); ht.add (-13601, "shu"); HT.Add (-13406, "shua"); ht.add ( -13404, "shuai"); ht.add (-13400, "shuan"); HT.Add (-13398, "shuan"); ht.add (-13395, "shui"); ht.add (-13391 "shun"); ht.add (-13387, "shuo"); HT.Add (-13383, "Si"); ht.add (-13367, "song"); ht.add (-13359, " Sou "); ht.add (-13356," su "); HT.Add (-13343," suan "); ht.add (-13340 "Sui"); HT.Add (-13329, "su"); ht.add (-13326, "suo"); HT.Add (-13318, "ta"); ht.add (-13147, " "); ht.add (-13138," tan "); ht.add (-13120," tang "); ht.add (-13107," tao "); HT.Add (-13096," te " Ht.Add (-13095, "teng"); HT.Add (-13091, "Ti"); HT.Add (-13076, "tian"); ht.add (-13068, "tiao");</p> <p>HT.Add (-13063, "TIE"); HT.Add (-13060, "ting"); HT.Add (-12888, "tong"); HT.Add (-12875, "tou"); HT. Add (-12871, "tu"); ht.add (-12860, "tuan"); ht.add (-12858, "tui"); HT.Add (-12852, "tun"); ht.add ( -12849, "TUO"); HT.Add (-12838, "WA"); HT.Add (-12831, "WAI"); ht.add (-12829, "wan"); ht.add (-12812 , "Wang"); HT.Add (-12802, "wei"); ht.add (-12607, "wen"); ht.add (-12597, "weng"); ht.add (-12594, " WO "); HT.Add (-12585," wu "); HT.Add (-12556," xi "); ht.add (-12359," xia "); ht.add (-12346," xian " HT.Add (-12320, "xiang"); HT.Add (-12300, "xiao"); ht.add (-12120, "xie"); ht.add (-12099, "xin"); HT.Add (-12089, "xing"); HT.Add (-12074, "xiong"); HT.Add (-12067, "xiu"); HT.Add (-12058, "xu"); HT. Add (-12039, "xuan"); ht.add (-11867, "xue"); HT.Add (-11861, "xun"); ht.add (-11847, "ya"); ht.add ( -11831, "yan"); HT.Add (-11798, "yang"); HT.Add (-11781, "yao"); ht.add (-11604, "ye"); ht.add (-11589 "Yi"); ht.add (-11536, "yin"); HT.Add (-11358, "ying"); ht.add (-11340, "yo"); ht.add (-11339, " "); ht.add (-11324," you "); ht.add (-11303," yu "); ht.add (-11097," yuan "); ht.a DD (-11077, "yue"); ht.add (-11067, "yun"); ht.add (-11055, "za"); HT.Add (-11052, "zai"); ht.add ( -11045, "ZAN"); HT.Add (-11041, "zang"); ht.add (-11038, "zao"); ht.add (-11024, "ze"); ht.add (-11020 "ZEI"); ht.add (-11019, "zen"); ht.add (-11018, "zeng"); ht.add (-11014, "zha"); HT.Add (-10838, " ");</p> <p>HT.Add (-10832, "zhan"); HT.Add (-10815, "zhang"); HT.Add (-10800, "zhao"); HT.Add (-10790, "zhe"); HT. Add (-10780, "zhen"); HT.Add (-10764, "zheng"); ht.add (-10587, "zhi"); ht.add (-10544, "zhong"); ht.add -10533, "ZHOU"); ht.add (-10519, "zhu"); HT.Add (-10331, "zhua"); ht.add (-10329, "zhuai"); ht.add (-10328 , "zhuan"); ht.add (-10322, "zhuang"); HT.Add (-10315, "zhui"); ht.add (-10309, "zhun"); ht.add (-10307, ​​" "); ht.add (-10296," zi "); ht.add (-10281," zong "); ht.add (-10274," zou "); HT.Add (-10270," zu " Ht.Add (-10262, "zuan"); HT.Add (-10260, "zui"); Ht.Add (-10256, "zun"); ht.add (-10254, "zuo"); HT.Add (-10247, "zz"); cache ["ht"] = ht;} void page_load (Object sender, eventargs e) {} #Region Web Form Designer Generated Code Override Protected Void Oninit (Eventargs E ) {/// codegen: This call is necessary for the ASP.NET Web Form Designer. // InitializeComponent (); base.onit (e);} /// <summary> /// Designer Supports the required method - Do not use the code editor to modify the // / this method.</p> <p>/// </ summary> private void InitializeComponent () {this.Button1.Click = new System.EventHandler (this.Button1_Click); this.Load = new System.EventHandler (this.Page_Load);} #endregion private void Button1_click (object sender, system.eventAndargs e) {if (cache ["ht"] == null) {b ();} HT = (HASHTABLE) Cache ["ht"]; string hz = this.TextBox1.text; This.Label1.text = (c (hz));}}} The approximate idea is this: 1. Create a hash table for the corresponding Chinese characters and pinyin, HT = (Hashtable) Cache ["ht" ]; 2, take out the internal code of the Chinese characters to see String C (String Hz) 3, take out the corresponding pinyin, see String G (int Num) a function! ! ! ! ! ! ! ! ! // ************************************************************************** Public string extract_hz (string hz) {byte [] zw = new byte [2]; long hz_int; zw = system.text.Encoding.default.getbytes (hz); // Get the array of byte from the salesle char // INT I1 = (short); // int I2 = (short) (Array [1] - OXA1); INT I1 = (ZW [0]); int i2 = (Short (Zw [1]); hz_int = I1 * 256 I2; // Expresstion // Table of the constant list // 'A'; //45217..45252 // 'b'; //45253..45760 // 'c'; //45761..46317 // 'd'; //46318..46825 // 'e'; //46826..47009 // 'f'; //47010..47296 //// 'G'; //47297..47613 // 'h'; //47614..48118 // 'j'; //48119..49061 // 'k'; //49062..49323 // 'L '; //49324..49895 //' m '; //49896..50370 //' n '; //50371..50613 //' o '; //50614..50621 //' p '; //50622..50905 // 'q';</p> <p>//50906..51386 // 'r'; //51387..51445 // 's'; //51446..52217 // 't'; //52218..52697 // no u, v // 'W'; //52698..52979 // 'x'; //52980..53640 // 'y'; //53689..54480 // 'z'; //54481..55289 // hz_int match The constant if ((Hz_INT> = 45217) && (Hz_INT <= 45252)) {RETURN "a";} IF ((Hz_INT> = 45253) && (Hz_INT <= 45760)) {Return "B";} IF (Hz_INT> = 45761) && (Hz_int <= 46317)) {RETURN "C";} IF ((hz_int> = 46318) && (Hz_INT <= 46825)) {RETURN "D";} if ((hz_int> = 46826) && (hz_int <= 47009)) {RETURN "E";} IF ((hz_int> = 47010) && (hz_int <= 47296)) {return "f";} if ((hz_int> = 47297) && Hz_int <= 47613)) {Return "G";} // ************************* IF ((hz_int> = 47614) && (Hz_int <= 48118)) {//messagebox.show("h "); return" h ";} if ((hz_int> = 48119) && (hz_int <= 49061)) {RETURN" J ";} IF (Hz_INT> = 49062) && (Hz_int <= 49323)) {RETURN "K";} IF ((Hz_INT> = 49324) && (Hz_int <= 49895)) {Return "L";} if ((hz_int> = 49896) && (hz_int <= 50370)) {r ETURN "M";} IF ((hz_int> = 50371) && (Hz_INT <= 50613)) {RETURN "N";} IF ((Hz_INT> = 50614) && (Hz_INT <= 50621)) {Return "O" } IF ((Hz_INT> = 50622) && (Hz_INT <= 50905)) {RETURN "P";</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-118616.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="118616" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.043</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'o3D4061MFf2b8m1vztD38qtuV0GsYcDbg3nfeoe6pe2qX8B5JsEakjW08cYoaPd7OfohcLcuHpOeTR4T'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>