且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

中文字符-PHP编码

更新时间:2023-02-21 19:04:28

中文通常是UTF-8,是的。您遇到的问题可能不是不是正确接收了数据(cURL知道它在做什么),而是您没有正确将数据发送到浏览器。

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');

这将告诉浏览器您正在发送UTF-8信息。

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

更新:如果这不起作用,则可能是PHP本身未正确处理它们。尝试在 echo 中稍微使用 utf8_encode utf8_decode 。如果该方法无效,则cURL不能正确解码流,这意味着您必须在响应中查找 Content-Type 标头并解码流。

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.