开发者

Character encoding issue. Single source displays multiple ways on single page

I have a strange character encoding issue.

I have a page where text is pulled from my database and displayed once on the page, once in the title, and once in a jquery ui modal dialog.

The character is an n with a tilde over it. It is from the same field/column/record in the database.

On the page it is fine. In the title it appears as the diamond/question mark. In the dialog it appears as the diamond/question mark. On a previous page, (it is a CMS, so all the headers are the same) it displays, in the page, as the diamond/question mark.

So what am I missing?

Charset and collation set as UTF8 in MYSQL.

Page header is UTF8 <meta http-equiv="Content-Type" conten开发者_开发问答t="text/html; charset=UTF-8" />

I even did this in php:

ini_set('default_charset', 'utf-8');
header('Content-Type: text/html; charset=utf-8');
header('Accept-Charset: utf-8');
header('Accept: text/html');

mb_language('uni');
mb_internal_encoding('UTF-8');

iconv_set_encoding("input_encoding", "utf-8");
iconv_set_encoding("internal_encoding", "utf-8");
iconv_set_encoding("output_encoding", "utf-8");

So, I could understand if it wasn't showing right in all places, but differently on one page is messing with my mind.

Thanks for any help.


So, I'm sort of not so bright. I being by saying that first off, adding SET NAMES fixed many problems across the board. So thank you for that. I will be putting this bit into all of my connection scripts from now on:

mysql_query("SET NAMES UTF8");

I found my error was at this line:

echo htmlentities($person_name);

So, once everything was properly dispalying as utf-8, I still got the

Muñoz

because it seems that you can't convert 3 and 4 byte utf8 characters using htmlentities(). See links below.

http://www.php.net/manual/en/function.htmlentities.php#96648

This issue is also discussed at:

http://www.php.net/manual/en/function.htmlentities.php#92105

Thanks for the help all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜