Test Cases of the format function >>
<< 美女对他说干什么都可以!!!!
Transform the messages_zh_CN.properties

Author Zhou Renjian Create@ 2005-01-28 14:17
whizz Note icon
<textarea id="source" cols="80" rows="25"></textarea>
<button onclick="transform();">Transform</button>
<script type="text/javascript">

var digitArray = new Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
function toHex(n){
    var result = ''
    var start = true;
    for (var i=32; i>0;){
        i-=4;
        var digit = (n>>i) & 0xf;
        if (!start || digit != 0){
            start = false;
            result += digitArray[digit];
        }
    }
    return (result==''?'0':result);
}
function transform() {
    var srcEl = document.getElementById("source");
    var str = srcEl.value;
    var rst = "";
    for (var i = 0; i < str.length; i++) {
        if (str.charCodeAt(i)  > 255) {
            rst += "\\u" + toHex(str.charCodeAt(i));
        } else {
            rst += str.charAt(i);
        }
    }
    srcEl.value = rst;
}
</script>
本记录所在类别:
本记录相关记录: