Search code examples
phpmysqlencodingmysql-real-escape-stringapostrophe

mysql_real_escape_string and apostrophe problem


so I've been using mysql_real_escape_string to insert data into my database...but then when I do that it replaces all apostrophes with the symbol ’

so instead of display it's, it's displaying it’s.......

is there a way to reconvert those ’'s into apostrophes when I read back from the database?


Solution

  • This is some character encoding issue in some way.

    Because in UTF-8, (U+2019) is encoded with 0xE28099. And that represents the characters â (0xE2), (0x80), and (0x99) in Windows-1252.

    So it seems that you just forgot to specify your output character encoding properly so that the browser uses its default character encoding Windows-1252 instead.