0

Encoding/Decoding working differentlty on different servers. Locally I'm running PHP v5.6. default_charset = UTF-8 according to php_info(). When I pass the value 's in the URL it displays correctly in an input field as 's.

Remotely my Godaddy server is running PHP v5.3, default_charset = No value according to php_info() When I pass the value 's in the URL it displays incorrectly in the input field as %27s.

I have added <meta http-equiv="content-type" content="text/html; charset=utf-8"></meta> in the header of the html file.

Does anyone know how to resolve this so that 's displays as 's on the remote server?

3
  • that has nothing to do with charsets. it's a proper uri-encoded uri Commented Jan 30, 2015 at 16:10
  • I should have noted that I get the same results regardless if I pass the 's through htmlspecialchars() or any other encoding or decoding functions. Commented Jan 30, 2015 at 16:21
  • htmlspecialchars is pointless. that's for output into an html context. You're not outputting to a browser, you're outputting to a console. you need mb_convert_encoding() Commented Jan 30, 2015 at 16:23

3 Answers 3

0

Don't you have to scape the single quote with \' or \'?

Sign up to request clarification or add additional context in comments.

1 Comment

I believe that's only if I'm concerned about saving the value in the DB.
0

You need to pass the value through urldecode() before you display value in input field.

Comments

0

' is not a standard alphanumeric character so it gets URL-encoded with a method similar to this one for compatibility.

' is %27 hex or 39 decimal ASCII character.

2 Comments

I get the same results if I pass it through htmlspecialchars() before I display the 's
Decode the value before processing it farther with php.net/manual/en/function.urldecode.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.