V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
fim8
V2EX  ›  问与答

为什么有些JS和CSS里面的中文字符要转成十六进制的?

  •  
  •   fim8 · Mar 18, 2011 · 5662 views
    This topic created in 5520 days ago, the information mentioned may be changed or developed.
    有什么好的转换工具吗?
    2 replies    1970-01-01 08:00:00 +08:00
    BB9z
        1
    BB9z  
       Mar 19, 2011
    声明为unicode编码但文本未以相应格式编码则会出现问题,国内用GB系charset的页面用不着转换。

    其实转换很容易:
    function char2unicode(str){
    var output = '';
    for(i=0,length=str.length; i<length; i++)
    output +='\\'+ str.charCodeAt(i).toString(16);
    return output;
    }

    以前收集过一个现成的转换页面,一个月前还用了一次,现在居然找不到了,很是奇怪。
    lianghai
        2
    lianghai  
       Mar 19, 2011
    从编码层面上保证 UTF-8 是更好的方法。
    如果非要转换: http://rishida.net/tools/conversion/
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5397 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 09:05 · PVG 17:05 · LAX 02:05 · JFK 05:05
    ♥ Do have faith in what you're doing.