开发者

PHP - Encoding strikes again

I'm having encoding problems in my webpage, and it is driving me crazy. Let me try to explain

  • I have a meta tag defining utf8 as charset.
  • I'm including the scripts as utf8 too (<script type="text/javascript src="..." charset="utf8"></script>).
  • In .php files, I declare header('Content-Type: text/html; charset=utf8');
  • In my database (postgreSQL), I've made the query show lc_collate; and the return was en_US.UTF-8
  • I'm using AJAX
  • When I try to save the field value "n开发者_如何学Goame" as "áéíóú", I get the value "áéíóú" in the record set (using phpPgAdmin to view results).

What am I doing wrong? There's a way to fix it without using decode/encode? Someone have a good reference about theses issues?

Thank you all!


Maybe the client encoding is not set correctly? PostgreSQL automatically converts between the character encoding on the client and the encoding in the database. For this to work it needs to know what encoding the client is using. Safest is to set this when you open your connection using:

SET CLIENT_ENCODING TO 'UTF8';

For details see the docs


You might be storing the data as ISO-8859-1?


Try enconding to base64 and decoding on the other end.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜