Monday, October 8, 2007

JavaScript Convert Char to Ascii

function ToAscii(characher)
{
//Author: Surendra Sambana
//Purpose: This function returns Ascii value of a given char.
var counter;
for (counter = 0; counter< 256; ++ counter)
{
var to_hexa = counter.toString (16);
if (to_hexa . length == 1)
to_hexa = "0" + to_hexa;
to_hexa = "%" + to_hexa;
to_hexa = unescape (to_hexa);
if (to_hexa == characher)
break;
}
return counter;
}

No comments: