Forum Moderators: open

Message Too Old, No Replies

Character Encoding And Gremlins

character encoding

         

bernk

4:10 pm on Feb 18, 2008 (gmt 0)

10+ Year Member



Hi,

My issue spans at least a couple of the categories in the forums here, HTML being the most general of them so I thought this would be a good place to start.

I'm working on a Norwegian website which uses special Norwegian characters. The content that I am having some trouble/confusion with is dynamically pulled from a MySQL database.

I guess the biggest issue is inconsistency. For example, if I enter the word "Nørwegian" using my custom CMS it gets stored in the DB as "Nørwegian" (at least that's what phpMyAdmin shows), however still displays properly on the page when when requested out of the DB. Now, if I use phpMyAdmin to create a new entry it shows properly in the DB but displays the ? instead of the special character on the page.

I have made sure that my DB is utf8_unicode_ci, the fields are the same. The default charset is set on every page in the header to be utf-8. I am pretty freakin confused here. Also, this is happening on my local dev server which is MAMP. I have the default charset of my server set to utf8 also.

Any ideas here? Why does entering special characters through my own CMS vs. phpMyAdmin produce different results?

tedster

7:34 pm on Feb 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The thing here is to discrimate between:

1) the actual bytes that are stored in MySQL for a given character
2) how an interface or application renders those bytes on screen

It sounds like phpMyAdmin does not actually support the character set that the database is using. I'm not sure if you can extend that support or not.

patzblue

4:10 pm on Feb 20, 2008 (gmt 0)

10+ Year Member



I'm familiar with that issue but not with PHP & MySQL.

But from my previous experiences, most recent versions of databases will store string informations in unicode. By default the browsers will NOT support UTF8 or special unicode, so you need to add a "Codepage" instruction in the html/PHP file so the browser uses the correct codepage when displaying your accents and other characters who always get garbaged when the codepage is missing.

hope it helps !