How do I decode URL special % characters?

0 favourites
  • 7 posts
From the Asset Store
A collection of various soldier character sprites for creating a 2D platformer or sidescroller game
  • Apparently, URL's cannot pass certain symbols, and the URL is ENCODED replacing these symbols

    with a Percent sign (%) and as number.

    Example:

    Text String (URL) received:

    data%3Aimage%2Fjpg

    Decoded:

    data:image/jpg

    Question:

    Is there a plugin or built in Construct function to DECODE these URL strings?

    If not, does anyone know of a way to take an existing string, such as in the above example, and

    replace all of the ENCODED characters with the correct symbols?

    Tagged:

  • I am looking for a "Search and Replace" routine, function, or method?

  • ANSWER: Use the System Expression "RegexReplace" to SEARCH through a string and REPLACE any

    characters, or string of characters with another character or string of characters.

    Example: RegexReplace(Text.Text, "p", "g", "*")

    Searches the string saved in "Text.Text" for the letter "p" and replaces it with "*"

    The "g" is s GLOBAL FLAG property that just means to repeat the search and replace thru the

    entire string, not just ONCE or the FIRST occurrence.

    For my problem with URL special characters, I had to run several operations on the same string.

    The % is followed by the ASCII code for the character that was replaced by the browser.

    %3A = ":", etc.

    RegexReplace(Cookie_IN,"%3A","g",":")

    RegexReplace(Cookie_IN,"%2F","g","/")

    RegexReplace(Cookie_IN,"%2B","g","+")

    RegexReplace(Cookie_IN,"%3D","g","=")

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can use URLencode and URLdecode expressions.

    URLDecode("data%3Aimage%2Fjpg") = "data:image/jpg"

  • Thank you DOP !!

  • Hey DOP, I am also having trouble with the "Local Storage" in Construct..

    I can SET and GET variables ok "within" Construct, however, when I try to GET or SET

    those variables "outside" of Construct using standard javascript, I have no success.

    I need to save Base64 image data for use by other web pages, not Construct related.

    The Base64 data can be large, so Cookies don't work, and passing these values within a

    URL doesn't work either. Both cases, the file size exceeds the limits.

    I found that I can save these large Bas64 image data strings to Local Storage, thinking I

    could access them from another web page using standard javascript, NOT...

    Any ideas?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)