(function($){
	application.lib.utf8 = {
		encode: function(txt) { 
		    txt = txt.replace(/\r\n/g,"\n");
		    var utf8txt = "";
		    for(var i=0;i<txt.length;i++) {        
		        var uc=txt.charCodeAt(i); 
		        if (uc<128) {
		            utf8txt += String.fromCharCode(uc);        
		        } else if((uc>127) && (uc<2048)) {
		            utf8txt += String.fromCharCode((uc>>6)|192);
		            utf8txt += String.fromCharCode((uc&63)|128);
		        } else {
		            utf8txt += String.fromCharCode((uc>>12)|224);
		            utf8txt += String.fromCharCode(((uc>>6)&63)|128);
		            utf8txt += String.fromCharCode((uc&63)|128);
		        }        
		    }
		    return utf8txt;
		}
	};
})(jQuery);

