Reputation: 591
I am trying to upload text into my database. I keep getting encoded text when user input certain characters. For example, if the user inputs "Jalapeño" I end up getting "Jalape%C3%B1o" in my database.
I know this is because the "ñ" is being read as "%C3%B1"...
I am not exactly sure how to go about converting all of the potential accented characters, I have looked at rewurldecode and others, but am wondering if there is a quick solution here. Any recommendations would be wonderful. Thank you!
Upvotes: 0
Views: 126
Reputation: 26699
Your character is urlencoded. To display it properly, you have to decode it. But url encoding is not meant to be used when saving data in the database. As dtech points, you have to use utf8 character set.
Upvotes: 0
Reputation: 14060
Make sure your database uses the right character set and collation (usually you'll want UTF-8). Also make sure you you set the connection character set and sent the right headers.
e.g. mysql:
mysql_connect();
mysql_set_charset("utf8");
header('Content-Type: text/html; charset=utf-8');
You could also use htmlentities
to convert the special characters into HTML entities, but you'll still need to make sure your database collation and connection settings are correct.
Upvotes: 1