1

I have special characters like # & and so on. What was suggested is I html decode these characters before passing them to my PHP image generator (a font previewer like things remembered).

I have no issues turning the text into html decoded, but how do I turn them back to encoded on the page the text gets submitted to?

bbcompent1
  • 494
  • 1
  • 10
  • 25

1 Answers1

1

The PHP superglobals $_GET and $_POST should be automatically decoded if you send a properly encoded data from the client side, I.E. using encodeURIcomponent() js function.

If it doesn't seem to be decoded for some reason, you should find out why (maybe you double-encoded it?), or bypass it like with urldecode() php func (there is also a workaround for utf8 decoding).

Dorad
  • 3,413
  • 2
  • 44
  • 71
  • 1
    Hello Dorad, I've tried everything I can think of with no success. I'm going to alter the original post and add my code to it so you can tinker with it and figure out what's going on. Items of note: PHP Version - 5.6 Fast CGI | Server is a VPS provided by DreamHost. – bbcompent1 Nov 08 '18 at 15:54
  • I appreciate it :) – bbcompent1 Nov 08 '18 at 16:41
  • I found the code, its in a previous thread: https://stackoverflow.com/questions/43979894/getting-php-code-to-recognize-special-characters – bbcompent1 Nov 08 '18 at 16:42
  • 1
    You're welcome. Could you explain what is the specific problem? – Dorad Nov 08 '18 at 16:48
  • Sure, the following characters cause various issues. The # + and \ characters will not appear. The & character truncates itself and all characters to the right. The character ' erases the entire line of text. – bbcompent1 Nov 08 '18 at 17:49
  • 1
    Because i am still not sure what is the problem, and this is going to be a long conversation here, i have sent you a mail. Please check if it didn't reach the spam folder. If it will be solved, we should both edit the q&a to what we achieved. – Dorad Nov 08 '18 at 18:19
  • Special thanks to @Dorad for helping me get this guy resolved. Kudos! – bbcompent1 Nov 21 '18 at 11:46