Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 911209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:09:58+00:00 2026-05-15T17:09:58+00:00

I’m using tiled to create a tile map. (Tiled is a tile map editor

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:09:59+00:00Added an answer on May 15, 2026 at 5:09 pm

    Try looking at the returned string character by character. In other words, get the “charCodeAt” for each character in the array.

    function codesFromString(str) {
      var rv = [];
      for (var i = 0; i < str.length; ++i)
        rv.push(str.charCodeAt(i));
      }
      return rv;
    }
    

    That leaves you with an array of numbers. If you want to dump that out as CSV on a page or something, you can use join()

    var csv = codeFromString(decoded).join(',');
    

    edit — ok here’s a base64 numeric decoder:

      var base64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split("");
      var base64inv = {}; 
      for (var i = 0; i < base64chars.length; i++) { 
        base64inv[base64chars[i]] = i; 
      }
      function decodeNumeric(s) {
        s = s.replace(new RegExp('[^'+base64chars.join("")+'=]', 'g'), "");
    
        var p = (s.charAt(s.length-1) == '=' ? 
                (s.charAt(s.length-2) == '=' ? 'AA' : 'A') : ""); 
        var r = []; 
        s = s.substr(0, s.length - p.length) + p;
    
        for (var c = 0; c < s.length; c += 4) {
          var n = (base64inv[s.charAt(c)] << 18) + (base64inv[s.charAt(c+1)] << 12) +
                  (base64inv[s.charAt(c+2)] << 6) + base64inv[s.charAt(c+3)];
    
          r.push((n >>> 16) & 255);
          r.push((n >>> 8) & 255);
          r.push(n & 255);
        }
        return r;
      }
    

    That works on your sample, but it demonstrates that what you’ve written as the result is not actually correct. Instead of “141,142,143,…” it’s “141,0,0,0,142,0,0,0,143,0,0,0” etc. That’s what those runs of “AAA” in the encoded string are.

    (code stolen from http://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64 )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 523k
  • Answers 523k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You are telling javac to compile gamedata.txt and it is… May 16, 2026 at 9:31 pm
  • Editorial Team
    Editorial Team added an answer Ultimately, RAD tools like mobiforms give you a "lowest common… May 16, 2026 at 9:31 pm
  • Editorial Team
    Editorial Team added an answer It sounds like you've either not got Option Strict on.… May 16, 2026 at 9:31 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
Does anyone know how can I replace this 2 symbol below from the string
In order to apply a triggered animation to all ToolTip s in my app,
I want to count how many characters a certain string has in PHP, but
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.