本文介绍了来自InternetReadFile的Unicode内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在Unicode模式的客户端应用程序中使用wininet.通常,它可以正常工作.

我将下载内容放入char *缓冲区中,并在每个InternetReadFile上构建了一个std :: string.由于我认为我正在获取UTF8编码的网页,因此在下载全部内容后,我将使用CA2W(buffer,CP_UTF8)进行转换.


但是,我想知道如何知道下载文件的字符集编码是什么?

我知道/if/是UTF8,我应该将其转换.但是,如果不是UTF8,该怎么办?如果是UTF16或ISO-8859-1或ANSI怎么办?

我可以使用GetQueryInfo来获取内容类型.我是否需要解析才能找到编码?我将尝试下一个.

I''ve been using wininet in a client-side application in Unicode mode. Mostly, it''s working.

I put the download into a char* buffer and build out a std::string on each InternetReadFile. Since I think I''m getting a UTF8 encoding web page, I use CA2W(buffer,CP_UTF8) to convert after I''ve downloaded it all.


However, I''m wondering how I know what the charset encoding is of the downloaded file...

I understand that /if/ it is UTF8, I should convert it. But what if it isn''t UTF8? What if it is UTF16 or ISO-8859-1 or ANSI?

I can use GetQueryInfo to get the content type. Do I need to parse this to find the encoding? I''m going to try that next.

推荐答案


这篇关于来自InternetReadFile的Unicode内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 00:25