Unicode编码转换器

    今天在看一个项目的properties文件时,看到里面全部都是这种字符gerenListXLS=\u666e\u901a\u7528\u6237\u8ba2\u5355\u5217\u8868.xls,其实properties文件中不能写中文字符,要不会出现乱码,必须将中文进行Unicode编码。
    常见Unicode和中文编码转换有两种方式:1、myeclipse的properties文件编辑器,直接输入它就可以给你转换,2、jdk自带的工具:native2ascii。可惜呀,我用的是eclipse,并且native2ascii不能用,于是就上网找了别人的这段代码修改了一下,基本核心内容还是和别人一样,挺好用的:

<!-- saved from url=(0011)about:blank -->
<html>
  <script language=javascript>
    function f(){
      var ta = document.getElementById("a");
      var tb = document.getElementById("b");
      tb.value = unescape(
        escape(ta.value).replace(/%u/g,"\\u") );
      //window.clipboardData.setData("text",tb.value);
    }
    function g(){
      var ta = document.getElementById("a");
      var tb = document.getElementById("b");
      ta.value = unescape(
        escape(tb.value).replace(/%5[Cc](u[0-9a-zA-Z]{4})/g /*\uXXXX*/,"%$1") );
      //window.clipboardData.setData("text",ta.value);
    }
    function func(){
      var ta = document.getElementById("a");
      var tb = document.getElementById("b");
      tb.value = tb.value.toLowerCase();
    }
  </script>
  <body>
    <div align=center>
     中文:<textarea id=a style="width:600;height:270"
      onkeydown="if(event.keyCode==13&&event.ctrlKey)f()"></textarea><br><br>
      <input type=button value="&darr;" onclick="f()" style="width:50">
      &nbsp;
      <input type=button value="&uarr;" onclick="g()" style="width:50">
      &nbsp;
      <input type=button value="A/a" onclick="func()" style="width:50">
      <br><br>
      Unicode:<textarea id=b style="width:600;height:270"
      onkeydown="if(event.keyCode==13&&event.ctrlKey)g()"></textarea>
    </div>
  </body>
</html>

这里写图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值