MySQL Forums
Forum List  »  PHP

Re: Unwanted character conversions
Posted by: Robert Hairgrove
Date: February 11, 2013 04:47PM

I fixed it now. Seems silly, but setting the MySQL character set explicitly to 'utf8' before the function call was what did the trick.

Somewhere deep down within MySQL and/or PHP, there seems to be a bug here. The trouble is that I always call htmlentities() on any strings I get from the database which might contain extended characters and need to be displayed in HTML. Perhaps our version(s) of MySQL and PHP are a little old, but I have had a lot of trouble using that function in the past when the input was UTF8. Since our server gives you HTML pages in ISO-8859-1 by default, I always send out the PHP header to get them in UTF8. But the MySQL API ignores this, returning the strings in Latin1. The htmlentities function seems/seemed to like it better that way, so I didn't bother with setting the MySQL charset explicitly.

Now it seems that if I DON'T set it to UTF8, it is going behind my back and converting "oe" to "ö" ... but Latin1 "ö", which of course does not display properly in a UTF8 web page. The bug is that this is being converted at all when it is really ASCII text all along. But is it a MySQL bug, or a PHP bug? Where do I submit the bug report???

Options: ReplyQuote


Subject
Written By
Posted
Re: Unwanted character conversions
February 11, 2013 04:47PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.