I'm using tiled to create a tile map. (Tiled is a tile map editor with support for orthogonal and isometric maps)
It saves the map in an XML file. It can use certain encoding structures:
- regular base64
- base64 + gzip
- base64 + zlib
- regular csv
Now, I've completely given up on gzip (my server gzips traffic it anyway, so no loss there) So I thought I'd try regular base64 decoding, using a base64 jquery plugin
But the data comes out all garbled, like this:
��������������������������������������������������������
I guess it's binary encoding it, but how do I get around that?
Example data that needs to be decoded (regular base64):
jQAAAI4AAACPAAAAkAAAAJEAAACSAAAAkwAAAKEAAACiAAAAowAAAKQAAAClAAAApgAAAKcAAAA=
Example data that needs to be decoded (gzipped base64):
H4sIAAAAAAAACw3DhwnAMAwAMP8P2Rdk9s1KoBQR2WK12R1Ol9vj9fn5A/luZ4Y4AAAA
Example data as csv:
141,142,143,144,145,146,147,
161,162,163,164,165,166,167
So how can I turn the regular base64 encoded bit and turn it into the csv?
Edit:
Using the solution Pointy found I got a semi-correct array. After a few thousand characters the 2 numbers would be wrong again, though. And even more frequent after that.
I then found someone who also uses tiled and the base64 encoding in his scheme. After he decoded the array, he also did this to it:
var d = base64_decode($(this).find('data').text());
var e = new Array();
for (var i = 0; i <= d.length; i += 4) {
var f = d[i] | d[i + 1] << 8 | d[i + 2] << 16 | d[i + 3] << 24;
e.push(f)
}
I have no idea why this is needed, but at least it works. If anyone could explain, please do!