0

I keep getting these weird text characters when I display user submitted text. like in the following example below. Is there a way I can fox this using PHP, CSS or something so that the characters are displayed properly?

Here is the problem text.

Problems of �real fonts� on the web. The one line summary: 
different browsers and different platforms do �hinting�

Here is my meta tag.

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
4

4 に答える 4

2

It's an encoding problem. Make sure you send the correct encoding to the browser. If it's UTF-8, you'll do it like this:

header("Content-type: text/html; charset=utf-8");

Also, make sure that you store the content using the same encoding throughout the entire system. Set your database tables to utf8. If you're using MySQL, run the SET NAMES utf8 query when connecting to make sure you're running in UTF-8.

These weird characters occur when you suddenly switch encoding.

Also, some functions in PHP take a $charset parameter (e.g. htmlentities()). Make sure you pass the correct charset to that one as well.

To make sure that PHP handles your charset correctly in all cases, you can set the default_charset to utf-8 (either in php.ini or using ini_set()).

于 2010-07-27T06:34:34.747 に答える
0

Set your page to UTF-8 encoding.

于 2010-07-27T06:34:19.520 に答える
0

Please check with the char-set in header section.

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
use this below one:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

or try this one:

htmlentities($str, ENT_QUOTES);
于 2010-07-27T06:41:00.033 に答える
0

Could be problem with file encoding please check that your files is correctly encoded, saved as "UTF-8 without boom", also if you are saving to database use SET NAMES UTF-8

于 2010-07-27T06:46:58.240 に答える