I would like to read data from a application/octet-stream charset=binary
file with fread
on linux and convert it to UTF-8
encoding. I tried with iconv
, but it doesn't support binary
charset. I haven't found any solution yet. Can anyone help me with it?
Thanks.
According to the MIME that you've given, you're reading data that's in non-textual binary format. You cannot convert it with iconv
or similar, because it's meant for converting text from one (textual) encoding to another. If your data is not textual, then a conversion to any character encoding is meaningless and will just corrupt the data, but not make it any more readable.
The typical way to present binary as readable text for inspection is hex dump . There's an existing answer for implementing it in c++: https://stackoverflow.com/a/16804835/2079303
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.