/*  Diese JS wird benötigt für den rss/xsl von originale-setzen-zeichen.de/rss/js_m.aspx
*   da der IE sonst sonderzeichen nicht richtig anzeigt
*/


function decode_utf8(utftext) {
    /*
     var plaintext = ""; var i=0; var c=c1=c2=0;
     // while-Schleife, weil einige Zeichen uebersprungen werden
     while(i<utftext.length)
         {
         c = utftext.charCodeAt(i);
         if (c<128) {
             plaintext += String.fromCharCode(c);
             i++;}
         else if((c>191) && (c<224)) {
             c2 = utftext.charCodeAt(i+1);
             plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
             i+=2;}
         else {
             c2 = utftext.charCodeAt(i+1); c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
             //plaintext += "["+ String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63)) +"]";
             switch(c3) {
                case 382:
                    plaintext += String.fromCharCode(8222);
                break;
                case 339:
                    plaintext += String.fromCharCode(8221);
                break;
                case 8482:
                    plaintext += String.fromCharCode(8217);
                break;
                
                case 97:
                    plaintext += String.fromCharCode(8222);
                break;
                case 101:
                    plaintext += String.fromCharCode(8222);
                break;
             } 
             
             //alert(c3);
             
             //plaintext += i+"["+ String.fromCharCode(8222) +"]";
             i+=3;}
         }
         
     if(navigator.appVersion.match(/MSIE/)) {
        document.writeln(plaintext);
     }else {
        document.writeln(utftext);
     }
     */
     
     document.writeln(utftext);
 }
 
 
function encode_utf8(rohtext) {
     // dient der Normalisierung des Zeilenumbruchs
     rohtext = rohtext.replace(/\r\n/g,"\n");
     var utftext = "";
     for(var n=0; n<rohtext.length; n++)
         {
         // ermitteln des Unicodes des  aktuellen Zeichens
         var c=rohtext.charCodeAt(n);
         // alle Zeichen von 0-127 => 1byte
         if (c<128)
             utftext += String.fromCharCode(c);
         // alle Zeichen von 127 bis 2047 => 2byte
         else if((c>127) && (c<2048)) {
             utftext += String.fromCharCode((c>>6)|192);
             utftext += String.fromCharCode((c&63)|128);}
         // alle Zeichen von 2048 bis 66536 => 3byte
         else {
             utftext += String.fromCharCode((c>>12)|224);
             utftext += String.fromCharCode(((c>>6)&63)|128);
             utftext += String.fromCharCode((c&63)|128);}
         }

     if(navigator.appVersion.match(/MSIE/)) {
        document.writeln(utftext);
     }else {
        document.writeln(rohtext);
     }
 }

