changed creole.js to use a new style ascii-to-hex conversion

This commit is contained in:
hyung-hwan 2015-03-17 04:17:26 +00:00
parent 47b17bdcf4
commit 5e58b3eda2

View File

@ -196,12 +196,52 @@ var asciiToHex = function (x,dir) {
if (dir == "A2H") if (dir == "A2H")
{ {
var i; var i;
for(i=0; i<x.length; i++) /*
for(i = 0; i < x.length; i++)
{ {
var tmp = x.charCodeAt(i).toString(16); var tmp = x.charCodeAt(i).toString(16);
if (tmp.length == 1) r += "0"; if (tmp.length == 1) r += "0";
r += tmp; r += tmp;
} }
*/
r = "!"; // the new style conversion begins with an exclamation mark
for(i = 0; i < x.length; i++)
{
var seg;
var c = x.charAt(i);
if (c == "!")
{
seg = "!!";
}
else if (c == ":")
{
seg = "!:";
}
else if (c == "/")
{
seg = ":";
}
else if (c == "." || c == "_" || c == "-" || c == " ")
{
seg = c;
}
else
{
if (/^[A-Za-z0-9]$/.test(c))
{
seg = c;
}
else
{
var seg = x.charCodeAt(i).toString(16);
if (seg.length == 1) seg = "0" + seg;
}
}
r += seg;
}
} }
else else
{ {