简体   繁体   中英

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.

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??' (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 )

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?

don't understand why some chars are 8bit and diacritic chars are 16 bit

Most likely because it's UTF8 or perhaps even UTF16. And by default PHP assumes one character == one byte

and how should PHP know which one is which, but anyway, how should I decode it?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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