简体   繁体   English

PHP curl响应编码

[英]php curl response encoding

I am trying to process data that I got using curl, but I have issues with encoding - I am unable to find right way to handle it. 我正在尝试处理使用curl获得的数据,但是编码存在问题-我找不到正确的处理方式。

This is the text I got (in HEX) - '6B 64 6F 20 6D C3 A1' that should evaluate to string 'kdo má' but instead of it, it evaluates to 'kdo m??' 这是我得到的文本(用十六进制表示)-'6B 64 6F 20 6D C3 A1',应评估为字符串“ kdomá”,但取而代之的是“ kdo m ??”。 (actually, the last two chars aren't question marks but http://www.fileformat.info/info/unicode/char/c3/index.htm and http://www.fileformat.info/info/unicode/char/a1/index.htm ) (实际上,最后两个字符不是问号,而是http://www.fileformat.info/info/unicode/char/c3/index.htmhttp://www.fileformat.info/info/unicode/char /a1/index.htm

I don't understand why some chars are 8bit and diacritic chars are 16 bit and how should PHP know which one is which, but anyway, how should I decode it? 我不明白为什么有些字符是8位而变音符字符是16位,PHP应该如何知道哪一个是哪一个,但是无论如何,我应该如何解码呢?

don't understand why some chars are 8bit and diacritic chars are 16 bit 不明白为什么有些字符是8位而变音符号是16位

Most likely because it's UTF8 or perhaps even UTF16. 最可能是因为它是UTF8甚至UTF16。 And by default PHP assumes one character == one byte 默认情况下,PHP假定一个字符==一个字节

and how should PHP know which one is which, but anyway, how should I decode it? PHP应该如何知道哪个是哪个,但是无论如何,我应该如何解码它?

No. You have to tell it. 不,你必须告诉它。 Check mbstring: http://php.net/manual/de/book.mbstring.php or recode: http://php.net/manual/en/book.recode.php 检查mbstring: http : //php.net/manual/de/book.mbstring.php或重新编码: http : //php.net/manual/en/book.recode.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM