文字UTF8编码
来源:互联网 发布:斗鱼刷人气软件原理 编辑:程序博客网 时间:2024/05/21 04:26
采用UTF8编码保存的文件中,汉字可能会被识别为乱码,导致无法正常显示;可通过对汉字进行编码后保存,以解决乱码问题:
通过以上方法,可将汉字“换行”编码为“\u6362\u884C” 或 "换行"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>汉字UTF8编码</title><style type="text/css"><!-- body{ margin:0px; } .btn{ font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #666666; text-align: left; text-decoration: none; display: block; overflow: visible; margin-right: 10px; margin-left: 10px; } .btn a:hover { background-color: #d8dfea; border-top-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-bottom-style: solid; border-top-color: #333366; border-bottom-color: #333366; } .btn a { display: block; text-decoration: none; color: #666666; border-top-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-bottom-style: solid; border-top-color: #CCCCCC; border-bottom-color: #CCCCCC; width: 100px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 30px; overflow: visible; float: left; } html { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #333333; line-height: 18px; margin: 0px; } --> </style></head><body><textarea name="source" rows="14" id="source" style="width:99%"></textarea><br /><div class="btn"><a href="javascript:action('CONVERT_FMT1')"> <strong>Convert</strong> Fmort &#xxxx </a></div> <div class="btn"> <a href="javascript:action('CONVERT_FMT2')"> <strong>Convert</strong> Fmort \uxxxx </a> </div> <div class="btn"> <a href="javascript:action('RECONVERT')"> <strong>ReConvert</strong> To 汉字 </a> </div><div id="tt" style="display:none"></div> <textarea name="show2" rows="14" id="show2" style="width:99%"></textarea><script language="javascript" type="text/javascript"> var oSource = document.getElementById("source"); var oShow2 = document.getElementById("show2"); var oTt = document.getElementById("tt"); function action(pChoice){ switch(pChoice){ case "CONVERT_FMT1": oShow2.value = ascii(oSource.value); break; case "CONVERT_FMT2": oShow2.value = unicode(oSource.value); break; case "RECONVERT": oShow2.value = reconvert(oSource.value); break; } } function ascii(str){ return str.replace(/[^\u0000-\u00FF]/g,function($0){return escape($0).replace(/(%u)(\w{4})/gi,"\&#x$2;")}); } function unicode(str){ return str.replace(/[^\u0000-\u00FF]/g,function($0){return escape($0).replace(/(%u)(\w{4})/gi,"\\u$2")}); } function reconvert(str){ str = str.replace(/(\\u)(\w{4})/gi,function($0){ return (String.fromCharCode(parseInt((escape($0).replace(/(%5Cu)(\w{4})/g,"$2")),16))); }); str = str.replace(/(&#x)(\w{4});/gi,function($0){ return String.fromCharCode(parseInt(escape($0).replace(/(%26%23x)(\w{4})(%3B)/g,"$2"),16)); }); return str; } </script></body></html>
通过以上方法,可将汉字“换行”编码为“\u6362\u884C” 或 "换行"
- 文字UTF8编码
- UTF8编码
- UTF8编码
- utf8 编码
- utf8编码
- UTF8编码
- UTF8编码
- UTF8编码
- utf8编码
- UTF8编码
- UTF8编码-变长编码
- UTF8编码解码函数
- 编码UTF8,UCS...
- JAVA编码--Gbk-->Utf8
- utf8的编码算法
- UTF8编码原理
- PHP设置UTF8编码
- 换成Utf8编码
- NameLookupAndInterfacePrinciple2
- JS阻止事件冒泡
- javax.el.PropertyNotFoundException: Property 'begin' not found on type java.lang.String
- Struts 2 struts.xml详解(一)
- 【我所認知的BIOS】—>PCI SCAN
- 文字UTF8编码
- ibatis 映射
- 品果新作Movie360:用Camera360的方式拍电影
- SIM卡中UCS2编码的三种格式(80,81,82)分析
- 转载- linux中$的用法
- c# global::
- Android调节音量
- container_of 理解
- Android 中如何处理双击事件