0

In a web application I'm working on all the content seems fine, except for the content which seems to be retrieved from the database. Some special characters are used, and they break - so it's deffinatly a character encoding error somewhere.

When I manually in the browser try to switch from iso-8859-1 to utf-8 the database-content looks fine, but the static is messed up. And vice versa. So I suspect that the static content is iso-8859-1, and the content from the database is utf-8.

I've looked around for some configuration files which states the charset, but when I try changing it, nothing happen.

Will converting my database content to iso-8859-1 help maybe, so it correlates with the static content? In that case, how? I've tried changing the schema and collation but the effect was seamless.

Edit: My apologies. This is an MySQL database.

6
  • What database is this? Also, for many databases, once you create an instance of the database (or at least a schema) the encoding for that instance or schema is irrevocably set. So changing that config option will only help when you next create an instance or schema. It likely won't change the one you already have. Commented May 18, 2012 at 11:40
  • @QuantumMechanic My apologies. This is an MySQL database. And you say it's irrevocably set? Will creating a new database with and import/export the old content help maybe? Commented May 18, 2012 at 11:48
  • I don't know that it's irrevocably set (and definitely don't know that specifically for MySQL), but it is with some databases. (Oracle for example, IIRC). Commented May 18, 2012 at 11:51
  • 1
    Please post the query, the code snippet which processes the query and the output of SHOW CREATE TABLE for the tables involved. Commented May 18, 2012 at 11:55
  • How to handle UTF-8 in a web app Commented May 18, 2012 at 12:10

1 Answer 1

1

Maybe it is an issue with your client library that communicates to MySQL.

Before you try to retrieve data from the database, execute this query: SET NAMES 'utf8'

reference: http://forums.mysql.com/read.php?103,46870,47245#msg-47245

Hope this helps.

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

Comments

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.