<script language="javascript1.1">
<!--
// Script by Joseph K. Myers <e_mayilme@hotmail.com>.
// This script produces a Unicode string with the turnIntoUnicodeString() function.
// This script produces a Unicode string with the turnIntoSafeString() function.
// HTML is escaped into entities with the escapeHTML() function.
o=unescape;
p=escape;
function sg(a,a2,a3) {
var r='';
while (a.indexOf(a2)!=-1) {
var v1=a.indexOf(a2);
r+=a.substring(0,v1)+a3;
a=a.substring(v1+a2.length);
} return r+a;
}
function escapeHTML(a) {
a=sg(a,'&','&');
a=sg(a,'<','<');
a=sg(a,'>','>');
a=sg(a,'"','"');
return a;
}
function turnIntoSafeString(a) {
a = sg(a,'\\','\\\\'); // Backslash backslashes
a = sg(a,'\n','\\n'); // Backslash newlines (Unix, Windows, DOS).
a = sg(a,'\r','\\r'); // Backslash newlines (Macintosh).
a = sg(a,'\t','\\t'); // Backslash tabs.
a = sg(a,'"','\\"'); // Backslash double quotes.
return '"' + a + '"'; // Return quoted string.
}
function turnIntoUnicodeString(a) {
return 'unescape("' + p(a) + '")'; // Return packed Unicode value.
}
//-->
</script>
|