ttt0z
18.11.2008, 11:33
function convertToHex(num) {
var hex = '';
for (i=0;i<num.length;i++) {
if (num.charCodeAt(i).toString(16).toUpperCase().leng th < 2) {
hex += "�" + num.charCodeAt(i).toString(16).toUpperCase() + ";";
} else {
hex += "&#x" + num.charCodeAt(i).toString(16).toUpperCase() + ";";
}
}
return hex;
}
для проверки из слова hello должно получиться
hello
var hex = '';
for (i=0;i<num.length;i++) {
if (num.charCodeAt(i).toString(16).toUpperCase().leng th < 2) {
hex += "�" + num.charCodeAt(i).toString(16).toUpperCase() + ";";
} else {
hex += "&#x" + num.charCodeAt(i).toString(16).toUpperCase() + ";";
}
}
return hex;
}
для проверки из слова hello должно получиться
hello