Dreamweaver编辑UTF8网页时鼠标选择错位/不能精确定位的解决办法

使用Dreamweaver中用鼠标选择代码的时候,光标总是对不准。具体就是,在代码视图中,如果有中文,鼠标点击时,光标的落位总是不准确,总要往前偏位几个字符,即光标偏位了。其实以前也遇到这种情况,一直不知道是怎么回事。

问题分析:

Adobe Dreamweaver在UTF-8编码下, 中文占2个字符的位置。 Continue reading "Dreamweaver编辑UTF8网页时鼠标选择错位/不能精确定位的解决办法"

UTF8与GB2313编码互转HTML代码

代码如下:

<style type="text/css">
<!--body,td,th {
    font-size: 12px;
    color: #000000;}--></style>
<title>UTF-8字符与GB2312中文编码在线转换</title><body>
<table width="514" height="407" border="0" align="center" cellpadding="1" bordercolor="#666666" bgcolor="#EEEEDD" style="border-style: solid; border-color: rgb(204, 204, 204) gray gray rgb(204, 204, 204); border-width: 1px 2px 2px 1px;"><td>
<div align="center" id="mynav2" style="WIDTH: 100%">
  <p><strong>UTF8转换工具(UTF-8字符与GB2312中文编码在线转换)</strong></p>
  <div id="NewsContentLabel"><div align="center" id="mynav" style="WIDTH: 100%"><div align="center"></div>
    </div>
    <p align="center">使用方法:在下面的文本框中输入中文文字,按“转化”,即可将其转化为UTF-8字符。</p>
    <p align="left">再按“还原”,即可将其还原为简体中文。</p>
  </div>
  <div id="Message"></div>
 
  <p align=center>
    <textarea name="" cols=""  rows=13 id=code style="WIDTH: 95%">
</textarea>
</p>
  <p align=center>
   
    <input type=button onclick=encode(code,this) value=" 转 换 ">
    <script>
var mode="zhuan";
function encode(obj,btn){
   if(mode=="zhuan"){
       obj.value=obj.value.replace(/[^\u0000-\u00FF]/g,function($0){return escape($0).replace(/(%u)(\w{4})/gi,"&#x$2;")});
       btn.value=" 还 原 ";
       mode="huan";
   }else{
       obj.value=unescape(obj.value.replace(/&#x/g,'%u').replace(/;/g,''));
       btn.value=" 转 换 ";
       mode="zhuan";
   }
}
</script>
  </p>
</div></table>
<DIV align="center">
  <p>CopyRight <STRONG><A href="http://429006.com/">Pop's Blog</A><br>
      </p>
</DIV>