Skip to content Skip to sidebar Skip to footer

Displaying Some Sort Of Apostrophe (Currently Shows As Diamond)

Some rows in my database contain an apostrophe of sorts, that, when displayed with PHP, are converted to diamonds with a question mark in the center. Example, if it copies correctl

Solution 1:

Characters are encoded in different places.

MySQL has a particular character encoding. By default, it is not UTF-8 but rather latin1.

The HTML document you generate using PHP also has a particular character encoding specified. Finally, the actual bytes in the HTML document factually assume a particular character encoding, which if you're not careful can be different than the character encoding you specify for the document.

Verify that your MySQL encoding is set to UTF-8 as a first step. Note that MySQL can have the default character encoding for the database overridden on a per-table or even per-column basis.

You may be interested in this related post to get a deeper understanding of character encoding

Character Encoding and the รข€™ Issue

Update

Something put the data into the MySQL database in the first place. Perhaps that "something" was not using UTF-8 encoding.


Post a Comment for "Displaying Some Sort Of Apostrophe (Currently Shows As Diamond)"