/** | |
* 文字列を16進数に変換する | |
* 16進数ひとけたの場合は01 02 03と表記する | |
* | |
* @method hex | |
* @param {String} s 文字列 | |
* @return {String} result 16進数に変換した文字列 | |
*/ | |
function hex(s) { | |
var result=""; | |
for(var i=0;i<s.length;++i){ | |
var h = ("0"+s.charCodeAt(i).toString(16)).substr(-2); | |
result += h; | |
} | |
return result; | |
} | |
console.log("abc"); | |
console.log(hex("abc")); // 616263 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment