chinese chars - PHP encoding

馋奶兔 提交于 2019-12-06 13:27:11

Chinese is usually UTF-8, yes. The problem you're having is probably not that the data isn't received correctly (cURL knows what it's doing), but that you're not sending them correctly to the browser.

Try this on top of your page:

header('Content-Type: text/html; charset=utf-8');

This will tell the browser that you are sending UTF-8 information.

Update: if this doesn't work, it could be that PHP itself isn't handling them properly. Try playing with utf8_encode and utf8_decode a bit in your echo. If thàt doesn't work, then cURL isn't decoding the stream properly, which means you'll have to look for the Content-Type header in the response and decode the stream accordingly.

Try this,

1) create a new document and make sure the document is UTF-8 compatible

2) Use metal tag :

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

3) I wouldn't recommend forcing header into using utf-8, but simply use ini_set

ini_set('default_charset', 'UTF-8');

if you are calling curl function from a different page, make sure that page is able to carry UTF-8 characters and pass it onto UTF-8 compatible page.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!