This type of conversion is mainly used to encrypt JS Code.
These two functions refer to the code of the [script house] (http://www.jb51.net/html/200707/23/10560.htm), but his function is wrong, I don't know why the author wants to write that way, so I changed it.
Function unicode2chr (STR)
{
If (STR! = '')
{
VaR fret, tempstr;
Fret = '';
For (VAR I = 1; I <= Str. Length/4; I ++)
{
Tempstr = Str. Slice (4 * I-4, 4 * I );
Fret = fret. Concat ('% U'). Concat (tempstr );
}
Fret = Unescape (fret );
Return (fret );
}
Else
Return ('');
}
Function chr2unicode (STR)
{
If (STR! = '')
{
VaR fret, tempstr;
Fret = '';
For (VAR I = 1; I <= Str. length; I ++)
{
Tempstr = Str. charcodeat (I-1). tostring (16 );
If (tempstr. Length <4)
While (tempstr. Length <4)
Tempstr = '0'. Concat (tempstr );
Tempstr = tempstr. Slice (0, 4 );
Fret = fret. Concat (tempstr );
}
Return (fret. touppercase ());
}
Else
Return ('');
}