Invalid character error while using atob() method

前端 未结 2 1557
北恋
北恋 2021-01-14 07:17

I have read a question in stack overflow with this code work in IE 10 but not work in ie9,

but still i am facing issue on this.

var image = canvas.t         


        
2条回答
  •  别那么骄傲
    2021-01-14 07:48

    1) your base64 encoded string probably is not fully valid. you can try to use this code instead of atob

    var decodeBase64 = function(s) {
        var e={},i,b=0,c,x,l=0,a,r='',w=String.fromCharCode,L=s.length;
        var A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
        for(i=0;i<64;i++){e[A.charAt(i)]=i;}
        for(x=0;x=8){((a=(b>>>(l-=8))&0xff)||(x<(L-2)))&&(r+=w(a));}
        }
        return r;
    };
    

    2) I think it should be image = image.replace(/^[^,]+,/, '');

    3) As far as I know, support of the Blob in IE starts from version 10 - https://developer.mozilla.org/en-US/docs/Web/API/Blob

提交回复
热议问题