jwhite68 Posted September 24, 2007 Share Posted September 24, 2007 I have an issue with quotes showing as question marks on my webpage. I am sure its a UTF-8 related issue, but some of the facts surrounding the issue confuse me. The database is MySQL and stores the text as UTF-8. The PHP script simply takes the data from the database to a string: $desc = $info['description']; And the text itself, is in a HTML string in the database as: <P class=MsoNormal style=MARGIN: 0in 0in 0pt>The Golfers will enjoy their favorite sport on the Golf course only 5 min drive from “The Vineyards”.</P> I am pretty sure that the original source was MS Word, and that the double quotes, in this example, are the special quotes from Word and not the ASCII quotes. When the webpage displays, it displays with the Unicode encoding. So, database is UTF-8, assignment in PHP is simple assignment without any form of stripping, tag removal etc. And encoding on webpage is Unicode. So can anyone suggest why they arent being displayed? In the above example, the latter part of the text shows as ?The Vineyards? It seems to apply to double quotes for sure, but also to some single quotes, as I have other text that displays as it?s instead of it's. Quote Link to comment https://forums.phpfreaks.com/topic/70465-single-quotes-and-double-quotes-showing-as-on-web-page/ Share on other sites More sharing options...
jwhite68 Posted September 24, 2007 Author Share Posted September 24, 2007 Another piece of information. The data that was initially put into the 'description' field was read in from an Excel file, which in turn was output from another MySQL database export - where that database was in Latin1 encoding. Quote Link to comment https://forums.phpfreaks.com/topic/70465-single-quotes-and-double-quotes-showing-as-on-web-page/#findComment-354033 Share on other sites More sharing options...
effigy Posted September 24, 2007 Share Posted September 24, 2007 Those are smart quotes. Search the forums for "smart quotes" for various approaches. Quote Link to comment https://forums.phpfreaks.com/topic/70465-single-quotes-and-double-quotes-showing-as-on-web-page/#findComment-354046 Share on other sites More sharing options...
jwhite68 Posted September 24, 2007 Author Share Posted September 24, 2007 I can search for smart quotes, but its also doing this for a hyphen symbol to, and perhaps others that I havent found yet. Quote Link to comment https://forums.phpfreaks.com/topic/70465-single-quotes-and-double-quotes-showing-as-on-web-page/#findComment-354049 Share on other sites More sharing options...
effigy Posted September 24, 2007 Share Posted September 24, 2007 Are you sure it's a hyphen? It could be an en-dash. This post has some ideas. I still think there should be a way to convert from Windows-1252... Quote Link to comment https://forums.phpfreaks.com/topic/70465-single-quotes-and-double-quotes-showing-as-on-web-page/#findComment-354057 Share on other sites More sharing options...
jwhite68 Posted September 24, 2007 Author Share Posted September 24, 2007 It could be an en-dash. As I said, I am pretty sure the source was a Word document initially - but I dont have access to the source to check this. I did try following the post you suggested, but unfortunately its not resulted in any changes/improvements. Quote Link to comment https://forums.phpfreaks.com/topic/70465-single-quotes-and-double-quotes-showing-as-on-web-page/#findComment-354061 Share on other sites More sharing options...
jwhite68 Posted September 24, 2007 Author Share Posted September 24, 2007 I did find something in the recommended post. By putting the code: $body = ereg_replace(128, '', $body); // Euro symbol $body = ereg_replace(133, '...', $body); // ellipses $body = ereg_replace(8226, '', $body); // double prime $body = ereg_replace(8216, "'", $body); // left single quote $body = ereg_replace(145, "'", $body); // left single quote $body = ereg_replace(8217, "'", $body); // right single quote $body = ereg_replace(146, "'", $body); // right single quote $body = ereg_replace(8220, '"', $body); // left double quote $body = ereg_replace(147, '"', $body); // left double quote $body = ereg_replace(8221, '"', $body); // right double quote $body = ereg_replace(148, '"', $body); // right double quote $body = ereg_replace(8226, "*", $body); // bullet $body = ereg_replace(149, "*", $body); // bullet $body = ereg_replace(8211, "-", $body); // en dash $body = ereg_replace(150, "-", $body); // en dash $body = ereg_replace(8212, "-", $body); // em dash $body = ereg_replace(151, "-", $body); // em dash $body = ereg_replace(8482, '', $body); // trademark $body = ereg_replace(153, '', $body); // trademark $body = ereg_replace(169, '', $body); // copyright mark $body = ereg_replace(174, '', $body); // registration mark in a function, and invoking it to convert any description strring before being output has helped. Its resolved the hyphen, single and double quotes. But I now see an issue with a bullet point symbol thats showing as a question mark. Does anyone have a more comprehensive function, like the one above, that covers all situations? Quote Link to comment https://forums.phpfreaks.com/topic/70465-single-quotes-and-double-quotes-showing-as-on-web-page/#findComment-354107 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.