【问题标题】:How to get a string representation of hex? [duplicate]如何获得十六进制的字符串表示? [复制]
【发布时间】:2013-08-20 14:28:58
【问题描述】:

我试过了:

http://jsfiddle.net/CG8gx/1/

for(var i = 0x00; i <= 0x88; i++){
    i = i.toString();
    if (i.length === 1) { 
        i = "0" + i;
    }
    // console.log(i.length);
    console.log(i);
    // console.log(decodeURIComponent("%" + i));
}

toString() 将给出十进制表示。所以上面的代码坏了。

【问题讨论】:

    标签: javascript utf-8


    【解决方案1】:

    你可以试试这个

    for(var i = 0x00; i <= 0x88; i++){
        i = "0x" + i.toString(16);
    
        console.log(i);
    
    }
    

    会显示

    0x0
    0x1
    0x2
    ...
    

    【讨论】:

      猜你喜欢
      • 2021-12-22
      • 1970-01-01
      • 2019-07-27
      • 1970-01-01
      • 2018-02-26
      • 1970-01-01
      • 1970-01-01
      • 2015-07-29
      • 2012-03-24
      相关资源
      最近更新 更多