I have a wordpress blog feeding a webpage and in this page I'm getting some non ascii characters as output. One of them is this:
�
I'm wondering if anyone can explain how to either convert this to something UTF-8 or ISO-8859-1 friendly or just remove the annoyance altogether. Ideally I would just like to do a str_replace on it and be done with it altogether because it's happening repeatedly. I've looked at the data source itself and all it looks like to me is a double space.
Thanks!
DS
Strange characters in output
Moderator: General Moderators
Re: Strange characters in output
That's odd that a double space is producing that, as usually browsers just ignore them unless they are indicated by " ". Getting rid of this usually means using codes such as © (copyright symbol), < and > (< and > respectively).
Sorry I couldn't be more help, but it's hard to pinpoint the problem with that much information.
Sorry I couldn't be more help, but it's hard to pinpoint the problem with that much information.
Re: Strange characters in output
This character means you are either storing data in your database in a different encoding than you are outputting, or that utf-8 html entities are broken in the middle. For the first you'll have to configure your database connection collation and character set using:
For the second, make sure that for UTF8 you are using multibyte string functions instead of the regular ones.
Code: Select all
SET CHARACTER SET =
SET NAMES =
Re: Strange characters in output
If I was storing data in my database in a different type of encoding, wouldn't it be pretty obvious to me? Is there a way to check other than my looking at the actual data within the database fields?
I've checked out php multibyte functions, but I'm guessing they are not part of php 5.1.6 by default since I'm getting the following error:
Call to undefined function mb_convert_encoding ??
Sorry for the noob questions, this is all new stuff to me
I've checked out php multibyte functions, but I'm guessing they are not part of php 5.1.6 by default since I'm getting the following error:
Call to undefined function mb_convert_encoding ??
Sorry for the noob questions, this is all new stuff to me
Re: Strange characters in output
you might be storing it in utf-8 but your connection is set to a different collation (depending on the default in your mysql configuration). That's why I pointed you to the connection settings that affect the connection. You can read more here - http://dev.mysql.com/doc/refman/5.0/en/ ... ction.html
multibyte is an extension you need to load in your php configuration file. It has been available since php 4.0.6.
It's not mb_convert_encoding you should be worried about - rather, if you are manipulating strings (with function such as substr, strlen etc.) use the multibyte equivalent instead when dealing with utf8 data.
multibyte is an extension you need to load in your php configuration file. It has been available since php 4.0.6.
It's not mb_convert_encoding you should be worried about - rather, if you are manipulating strings (with function such as substr, strlen etc.) use the multibyte equivalent instead when dealing with utf8 data.
Re: Strange characters in output
Thanks so much pytrin! I ended up doing a little reading and discovered that all I needed to do was add this line to /etc/my.cnf:
init_connect='SET NAMES utf8'
Looks like I've got a lot more to learn about character encoding and how the client and server both handle this on their respective ends....
Thanks again!
DS
init_connect='SET NAMES utf8'
Looks like I've got a lot more to learn about character encoding and how the client and server both handle this on their respective ends....
Thanks again!
DS