I am converting a base64 String to byte array using atob() function.
我正在使用atob()函数将base64字符串转换为字节数组。
I get the base64String from below code:
我从下面代码得到base64String:
var dataURL = $("#graph-panel .canvasjs-chart-canvas").get(0).toDataURL();
Contents of dataURL is as follows:
dataURL的内容如下:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAAEiCAYAAACm31eYAAAgAElEQVR4nO3d+ZPc5n3n8f5f8D/AWZcrclLeILE2yuGsbG/KjuxNdg2tt7xOrPKqnLVK5dokiMobrx1XjnUgiZIMUhJ4ixSv4QGRw1O8xWvA+xje9zU8vvvD9NN8Go1G90x3D/A8eL+qUEU2Gt1PP0ADn37mwfM0BAAAAEDlNcouAAAAAIDeCO4AAACAAQjuAAAAgAEI7gAAAIABCO4AAACAAQjuAFAgSRJpNBqSJEnrsTRNW495nie+77dt4/u+eJ7X9TV935dGo9FaoigaWfmHKa8uAABzh+AOAD34vi+O47T+r4d1FWbTNBWR9lCfx/O8ttcSEXEcp7U9AADdENwBoA+qZVwFdZ0e5Ita26Mo6tg2S72+WvTW/CiKWu+lt9br2+Q9PwiC3PWq7GqdXu7sewVB0PpRon5kZMuq/1jRX1ffRmT6h4qqC7UAAHrjbAkAfVBBU4VOnd7Kng2pul5daPK6oqjQrJch+3/Vgp9t7VfrVVhX61X5fd9v+yz6uux76durz5dXFyLToV3/nOqHg+I4Ttv/87obAQA6EdwBoE+O43R0c1FUy3RRAPV9f8brgyBoheAoitrePxukRaZDsB6+s+UtKoNqne+2bV5wz75WXplEpO0HRTbwq9Z9AEAxgjsA9CEIglZw11uhlW6BVddPcM++th6g+w3uReE7CIK2MujdVbKt+b2Cu8iz1nMVvNVzsvSwnhfcu/0gAgA8Q3AHgB70LijdusP0E9x79XEfVot7UfjW3yP7I2SmLe469VqzbXEnuANAbwR3AOgh2wc7r696P8FdZDq0Zrf1PE/SNO3ax71b15d+grveip7tA68HaLVutsFdf9+8Pu76axHcAWB2CO4AUKBbK3l2/PV+g7tI54gr2RBbtG42Le76KDR6C3veCDb9Bnf177wRaUSedaHRb5…
The above base64 String is not a complete string I think. Whatever the string that got printed in the console I have pasted it above.
上面的base64字符串不是我想的完整字符串。无论在控制台打印的字符串是什么,我都将它粘贴在上面。
I am passing this base64 String to the following function:
我将这个base64字符串传递给以下函数:
var bytes = b64DecodeUnicode(dataUrl);
function b64DecodeUnicode(str) {
console.log(str);
// Going backwards: from bytestream, to percent-encoding, to original string.
return decodeURIComponent(atob(str).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
}
While executing the above code I am getting the following errror:
在执行上述代码时,我得到了以下错误:
InvalidCharacterError: String contains an invalid character
invalidcharacter错误:字符串包含无效字符。
[EDIT] Following is the complete Base64 String:
以下是完整的Base64字符串:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAAEiCAYAAACm31eYAAAgAElEQVR4nO3d+ZPc5n3n8f5f8D/AWZcrclLeILE2yuGsbG/KjuxNdg2tt7xOrPKqnLVK5dokiMobrx1XjnUgiZIMUhJ4ixSv4QGRw1O8xWvA+xje9zU8vvvD9NN8Go1G90x3D/A8eL+qUEU2Gt1PP0ADn37mwfM0BAAAAEDlNcouAAAAAIDeCO4AAACAAQjuAAAAgAEI7gAAAIABCO4AAACAAQjuAFAgSRJpNBqSJEnrsTRNW495nie+77dt4/u+eJ7X9TV935dGo9FaoigaWfmHKa8uAABzh+AOAD34vi+O47T+r4d1FWbTNBWR9lCfx/O8ttcSEXEcp7U9AADdENwBoA+qZVwFdZ0e5Ita26Mo6tg2S72+WvTW/CiKWu+lt9br2+Q9PwiC3PWq7GqdXu7sewVB0PpRon5kZMuq/1jRX1ffRmT6h4qqC7UAAHrjbAkAfVBBU4VOnd7Kng2pul5daPK6oqjQrJch+3/Vgp9t7VfrVVhX61X5fd9v+yz6uux76durz5dXFyLToV3/nOqHg+I4Ttv/87obAQA6EdwBoE+O43R0c1FUy3RRAPV9f8brgyBoheAoitrePxukRaZDsB6+s+UtKoNq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Bwz0iSRHzfL7sY4jhO2UUAAABAhYwkuDuOI41GQxqNRlsQDoKg9bi+eJ4nIiJpmuauV4t6Hf31s4sKvJ7ndX2Oer+sKIpa67q9RzZQd3teFEUiIuL7fuuxIAi61pleN0EQSJIk0mjwuwoAAADThp4Mfd9va7FWAbrtTZuBXkRaAVUP09nX0F9LiaIot1Vaf05e+FWPNRoNSdO09Xiaph2vl30P9cOi1/NUWFfhXX/PbtQPgGxZu/3IAAAAQL0MPbg7jtMKrEo2hOvBXa3Xg3S34K7rFtx13Vqt8wK453kd5c57D1XWXs/L/iVBtajntbpHUZT7ut3KBQAAgPoZenBXLex6MO9408x6FWqLgnv2/91Cta6ou4l6zyRJWkE+K/se6vX6KYvjOB3BvVs4932/a1mDIKDVHQAAAKPp46739da7o+jrVXDPa/3W+4Vn+7crURT17H9eFNzV9lEUdW29z75Htxb+7PbZ1nUV3NVn1VvQkyQp7NOeJAk3qgIAAGB0o8roN1tmW4x7Be65aHHvN7hnb3Ytei190bvEqOCuypj9kVJUVm5SBQAAgIgW3H+S7BQ3jGe1vDG+p+sb5PXt7tWVZtR93PVypWnaV3BXreV55epVFj24663u+uMEdwAAABQZenDP64+dDeKzDe6qW4lIcVhWZeh1c6r+vF7BXf0/29WlV1nU++k/XFSru+o+U1RWgjsAAABERhDcHcfJHUVGD7uzDe56n/mi4SCzwzDq8oZmVEE+2x+/aFQZ/fPMNLjn3eTKzakAAAAoMpJx3LN9vlXIzU7AlA2kvSZgUuG4aAImFcCLJmDqNka8Hsaz75H94dFtyRsKU1+vv5/68ZItqx7yGQ4SAAAAIiO8OdU0eRMwlY0JmAAAAKAQ3DX93PA6V7qNLQ8AAIB6IhlmJEnSc0SbuVCVHxAAAACoBoI7AAAAYACCOwAAAGAAgjsAAABgAII7AAAAYACCOwAAAGAAgjsAAABggP8PmhrfBzyexNsAAAAASUVORK5CYII=
2 个解决方案
#1
1
Looks like you're trying to convert a DataURL using the atob()
function, but you have missed a step.
看起来,您试图使用atob()函数来转换一个DataURL,但是您已经错过了一个步骤。
The DataURL contains information about the media type and the encoding like so:
DataURL包含关于媒体类型和编码的信息:
data:[<mediatype>][;base64],<data>
数据:[< mediatype >][;base64], <数据>
You can try retrieving only the data by using String Split on base64,
您可以尝试使用base64上的String Split来检索数据,
Try this:
试试这个:
data = str.split('base64,')[1];
data = str.split(“base64,”)[1];
Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
参考:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
#2
0
I have achieved the conversion with following code:
我已经完成了以下代码的转换:
var dataURL = $("#graph-panel .canvasjs-chart-canvas").get(0).toDataURL();
var byteArr = b64toArray(dataURL);
function b64toArray(b64Data){
var byteCharacters = atob(b64Data);
var byteNumbers = new Array(byteCharacters.length);
for (var i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
return byteArray;}
#1
1
Looks like you're trying to convert a DataURL using the atob()
function, but you have missed a step.
看起来,您试图使用atob()函数来转换一个DataURL,但是您已经错过了一个步骤。
The DataURL contains information about the media type and the encoding like so:
DataURL包含关于媒体类型和编码的信息:
data:[<mediatype>][;base64],<data>
数据:[< mediatype >][;base64], <数据>
You can try retrieving only the data by using String Split on base64,
您可以尝试使用base64上的String Split来检索数据,
Try this:
试试这个:
data = str.split('base64,')[1];
data = str.split(“base64,”)[1];
Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
参考:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
#2
0
I have achieved the conversion with following code:
我已经完成了以下代码的转换:
var dataURL = $("#graph-panel .canvasjs-chart-canvas").get(0).toDataURL();
var byteArr = b64toArray(dataURL);
function b64toArray(b64Data){
var byteCharacters = atob(b64Data);
var byteNumbers = new Array(byteCharacters.length);
for (var i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
return byteArray;}