core-jgi/utils_dev/trl/encode.html

42 lines
859 B
HTML

<html><head><title>js escape()/unescape() function</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"></head><body>
<pre>JavaScript escape()/unescape() function test
</pre>
<form name="encode">
<textarea rows="10" cols="60" name="src"></textarea>
<input onclick="utfEncode();" value="encode" type="button">
<textarea rows="10" cols="60" name="dest"></textarea>
<input onclick="utfDecode();" value="decode" type="button">
</form>
<script language="JavaScript">
function utfEncode(){
var str = document.encode.src.value;
str=escape(str)
str=str.replace(/%/g, "\\");
str=str.toLowerCase();
document.encode.dest.value=str;
}
function utfDecode(){
var str = document.encode.dest.value
str=str.replace(/\\/g, "%");
document.encode.src.value
=unescape(str);
}
</script>
</body></html>