开发者

Encoding problems while displaying formatted text with php

开发者 https://www.devze.com 2023-01-09 04:23 出处:网络
I have formatted english text stored in mysql. When I echo it out with php, I get a whole a lot of \"�开发者_JAVA百科 � � � � ���\" instead of where spaces should be. It looks fine in the DB.

I have formatted english text stored in mysql. When I echo it out with php, I get a whole a lot of "�开发者_JAVA百科 � � � � ���" instead of where spaces should be. It looks fine in the DB.

Whats the reason for that?


I have come across this problem before and what I have done is set the db and column collation to utf8_general_ci. And between my tags put the below meta line in.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Then I ran this query when I open my db connection: mysql_query("SET NAMES 'utf8'");

This helped me with multilingual websites quite a bit :-)


That will most likely have to do with either your database has a conflicting character set to that of your html document, or your server is pushing out the wrong character encoding for your html document.


if your characters looks OK in your DB: Try setting this php/html output-encode to the same encode you have in your DB...

What characters are? speaking language?...

0

精彩评论

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