Please help in my js file

Discussion in 'JavaScript' started by hallianonline, Feb 23, 2012.

  1. #1
    Hello
    i have a js file named as get.js
    I have a variable which have base64 encoded string in it and now I want its decoded values which writes in document.write function but I am getting blank results when I include this file in body of my html plz helllllppp me in this thanks

    here is the coding of my js file

        _utf8_decode : function (utftext) {
            var string = "PHRhYmxlIGJvcmRlcj0nMCcgY2VsbHBhZGRpbmc9JzAnIGNlbGxzcGFjaW5nPScwJyBzdHlsZT0nYm9yZGVyLWNvbGxhcHNlOmNvbGxhcHNlJyBib3JkZXJjb2xvcj0nIzExMTExMScgd2lkdGg9JzEwMCUnIGlkPSdBdXRvTnVtYmVyMScgYmdjb2xvcj0nI0ZGRkZGRic+PHRyPjx0ZCB3aWR0aD0nMTAwJSc+PGlmcmFtZSB3aWR0aD0nMTAwJScgc2Nyb2xsaW5nPSdubycgaGVpZ2h0PSc0MDAnIGZyYW1lYm9yZGVyPScwJyBzcmM9J2h0dHA6Ly93d3cudzNzY2hvb2xzLmNvbS8nIG5hbWU9J0kxJz48L2lmcmFtZT48L3RkPjwvdHI+PHRyPjx0ZCB3aWR0aD0nMTAwJSc+PHAgYWxpZ249J2NlbnRlcic+PGZvbnQgZmFjZT0nQXJpYWwnIHN0eWxlPSdmb250LXNpemU6IDZwdCc+PGEgdGFyZ2V0PSdfYmxhbmsnIGhyZWY9J2h0dHA6Ly93d3cudzNzY2hvb2xzLmNvbS8nIHN0eWxlPSd0ZXh0LWRlY29yYXRpb246IG5vbmUnPjxmb250IGNvbG9yPScjRkZGRkZGJz5NeSBXZWJzaXRlIGxpbms8L2ZvbnQ+PC9hPjwvZm9udD48L3RkPjwvdHI+PC90YWJsZT4=";
            var i = 0;
            var c = c1 = c2 = 0;
     
            while ( i < utftext.length ) {
     
                c = utftext.charCodeAt(i);
     
                if (c < 128) {
                    string += String.fromCharCode(c);
                    i++;
                }
                else if((c > 191) && (c < 224)) {
                    c2 = utftext.charCodeAt(i+1);
                    string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                    i += 2;
                }
                else {
                    c2 = utftext.charCodeAt(i+1);
                    c3 = utftext.charCodeAt(i+2);
                    string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                    i += 3;
                }
     
            }
     
            return string;
        }
     
    }
    
    
    
    
    document.write(string);
    Code (markup):

     
    hallianonline, Feb 23, 2012 IP
  2. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #2
    you didn't post the code completely.. its vague
     
    JohnnySchultz, Feb 29, 2012 IP
  3. trendint

    trendint Peon

    Messages:
    52
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    utf8 decoding won't help on a base64 encoded string - you are using two completely different data types.
     
    trendint, Feb 29, 2012 IP