Issue
I'm new here. I have a problem decoding my string in base64.
when I use https://www.base64decode.org/
It works perfectly, so I believe the problem is not my String but whenever I try to dart it doesn't work
I try to decode like this:
HtmlSac = utf8.decode (base64Url.decode (MyString))
He returns
FormatException: Missing extension byte (at offset 2451)
my String:
PCFET0NUWVBFIEhUTUw+DQoNCiANCiA8IS0tICoqKioqKioqIENSSUEgRlVOQ0FPICJOYUxpc3RhTmVncmEiIFFVRSBWRVJJRklDQSBTRSBPIENQRi9DTlBKIEVTVEEgTkEgTElTVEEgTkVHUkEgREEgUkVDRUlUQSAqKioqKioqKioqIC0tPg0KDQoNCjxodG1sPg0KCQ0KCTxoZWFkPg0KCQk8bWV0YSBodHRwLWVxdWl2PSJDb250ZW50LVR5cGUiIGNvbnRlbnQ9InRleHQvaHRtbDsgY2hhcnNldD1pc28tODg1OS0xIj4NCgkJPHRpdGxlPlJlY2VpdGEgRmVkZXJhbCBkbyBCcmFzaWw8L3RpdGxlPg0KICAgICAgICA8bGluayByZWw9InN0eWxlc2hlZXQiIGhyZWY9Ii8vd3d3LnJlY2VpdGEuZmF6ZW5kYS5nb3YuYnIvdGVtYS9jc3MvcmZiLmNzcyIvPg0KICAgICAgICA8c2NyaXB0IGRhdGEtbWFpbj0iLy93d3cucmVjZWl0YS5mYXplbmRhLmdvdi5ici90ZW1hL21haW4tYnVpbHQuanMiIHNyYz0iLy93d3cucmVjZWl0YS5mYXplbmRhLmdvdi5ici90ZW1hL3JlcXVpcmUuanMiPjwvc2NyaXB0Pg0KICAgICAgICA8c2NyaXB0IHNyYz0iLy93d3cucmVjZWl0YS5mYXplbmRhLmdvdi5ici9lc3RhdGlzdGljYS9lc3RhdGlzdGljYS5qcyI+PC9zY3JpcHQ+DQoJCQ0KCQ0KCQkNCgkJDQoJCTxzY3JpcHQgbGFuZ3VhZ2U9ImphdmFzY3JpcHQiID4NCgkJCWZ1bmN0aW9uIGFvU2FpcihldmVudG8pIHsNCgkJCQkvL2lmICh3aW5kb3cuRXZlbnQpIH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oJCWRvY3VtZW50Lm9ubW91c2Vkb3duPWNsaWNrDQoJPC9zY3JpcHQ+DQoJDQoJDQoJDQoJDQoJPC9ib2R5Pg0KPC9odG1sPg0K
Solution
Your bytes do not represent a valid UTF-8 string. It appears that they are, instead, encoded in ISO-8891-1 ("Latin-1").
Use this instead:
import 'dart:convert';
void main() {
var x = 'PCFET0NUW~~~~~~C9odG1sPg0K';
var decoded = latin1.decode(base64.decode(x));
print(decoded);
}
Answered By - Richard Heap
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.