- function ascii(str){
- return str.replace(/[^/u0000-/u00FF]/g,function($0){return escape($0).replace(/(%u)(/w{4})/gi,"//u$2")});
- }
- function unascii(str){
- return unescape(str.replace(///u/g,"%u"));
- }
- function convert(str)
- {
- result = "";
- for(i = 0 ; i < str.length ; i++) {
- c = str.charAt(i);
- if((' ' <= c && c <= '~') || (c == '/r') || (c == '/n')) {
- if(c == '&') {
- cstr = "&";
- } else if(c == '<') {
- cstr = "<";
- } else if(c == '>') {
- cstr = ">";
- } else {
- cstr = c.toString();
- }
- } else {
- cstr = "&#" + c.charCodeAt().toString() + ";";
- }
- result = result + cstr;
- }
- return result;
- }