var SafeFN={plain:"-./[_0123456789abcdefghijklmnopqrstuvwxyz",pre_indicator:"%",post_indicator:"]",changeSafeBase:function(a,c,b){if(isNaN(c)||c<2||c>36||isNaN(b)||b<2||b>36){throw (new RangeError("Illegal radix. Radices must be integers between 2 and 36, inclusive."))}a=parseInt(a,c);if(c==36){return a}return a.toString(b)},get_u_array:function(b){var c=new Array();for(var a=0;a<b.length;a++){c[a]=b.charCodeAt(a)}return c},safe_to_unicode:function(f){var a=new Array();var e=new RegExp("(?=["+this.pre_indicator+"\\"+this.post_indicator+"])");var b=f.split(e);var g=false;for(var c=0;c<b.length;c++){var d=b[c];if(d.charAt(0)!=this.pre_indicator){var h=g?1:0;for(j=h;j<d.length;j++){a.push(d.charCodeAt(j))}g=false}else{if(d.length==1){a.push(d.charCodeAt(0));g=true}else{a.push(32+this.changeSafeBase(d.slice(1),36,10));g=true}}}return a},unicode_to_safe:function(a){var e="";var g=false;var f=this.plain+this.post_indicator;for(var c=0;c<a.length;c++){codepoint=a[c];var b="";if(String.fromCharCode(codepoint)!="\\"){var d=new RegExp(String.fromCharCode(codepoint));var b=f.match(d)}if(codepoint<127&&b){if(g){e+=this.post_indicator;g=false}e+=String.fromCharCode(codepoint)}else{if(codepoint==this.pre_indicator.charCodeAt(0)){e+=this.pre_indicator;g=true}else{e+=this.pre_indicator+this.changeSafeBase((codepoint-32),10,36);g=true}}}if(g){e+=this.post_indicator}return e},encode:function(a){return this.unicode_to_safe(this.get_u_array(a))},decode:function(b){var a=this.safe_to_unicode(b);var d=new Array();for(var c=0;c<a.length;c++){d[c]=this.code2utf(a[c])}return this.utf8Decode(d.join(""))},chr:function(a){return String.fromCharCode(a)},code2utf:function(a){if(a<128){return this.chr(a)}if(a<2048){return this.chr(192+(a>>6))+this.chr(128+(a&63))}if(a<65536){return this.chr(224+(a>>12))+this.chr(128+((a>>6)&63))+this.chr(128+(a&63))}if(a<2097152){return this.chr(240+(a>>18))+this.chr(128+((a>>12)&63))+this.chr(128+((a>>6)&63))+this.chr(128+(a&63))}},_utf8Decode:function(g){var f=new Array();var e,b,a,h,c=0;for(var d=0;d<g.length;){e=g.charCodeAt(d++);if(e>127){b=g.charCodeAt(d++)}if(e>223){a=g.charCodeAt(d++)}if(e>239){h=g.charCodeAt(d++)}if(e<128){f[c++]=this.chr(e)}else{if(e<224){f[c++]=this.chr(((e-192)<<6)+(b-128))}else{if(e<240){f[c++]=this.chr(((e-224)<<12)+((b-128)<<6)+(a-128))}else{f[c++]=this.chr(((e-240)<<18)+((b-128)<<12)+((a-128)<<6)+(h-128))}}}}return f.join("")},utf8Decode:function(d){var c=new Array();var e=0;var a="";var b=0;while((e=d.search(/[^\x00-\x7F]/))!=-1){a=d.match(/([^\x00-\x7F]+[\x00-\x7F]{0,10})+/)[0];c[b++]=d.substr(0,e)+this._utf8Decode(a);d=d.substr(e+a.length)}c[b++]=d;return c.join("")}};function SafeFN_encode(a){return SafeFN.encode(a)}function SafeFN_decode(a){return SafeFN.decode(a)}function dwikiUTF8_encodeFN(a,b){if(b=="utf-8"){return a}if(a.match(/^[a-zA-Z0-9\/_\-\.%\]]+$/)){return a}if(b=="safe"){return SafeFN_encode(a)}a=encodeURIComponent(a);a=a.replace(/%2F/g,"/");return a}function dwikiUTF8_decodeFN(a,b){if(b=="utf-8"){return a}if(b=="safe"){return SafeFN_decode(a)}return decodeURIComponent(a)};