Link to home
Start Free TrialLog in
Avatar of Dave Shields
Dave Shields

asked on

Wininet to read websites AND disk files

I have written a Wininet program to access HTTP files and stdio files.  In Visual C++ 2003 it works OK.  When I update it for Visual C++ 2013, it works, but the program returns what look like Chinese characters.  I am using CInternetFile::ReadString as the utility to read the file.  MS documentation  for this function states that "it does not perform any manipulation of the data for example conversion to Unicode, so you must map the returned data to a structure you expect.

I would like to expect Unicode, as then I could read it.  Should I use another Wininet function, or map it to Unicode.  I need some landholding  with this problem, as mapping is beyond my pay grade and I am new to Wininet.
Avatar of jkr
jkr
Flag of Germany image

Have you set your project settings to UNICODE? If not, that might be the reason for the 'garbled' text. If you have done that - what's your code?
Avatar of Dave Shields
Dave Shields

ASKER

I did not know that I could set my project settings to UNICODE!  How can I do that??
Dave
Open your project properties (ALT+F7), go to "Configuration Properties|C/C++|General" and change "Use Character Set" from "Multibyte" to "UNICODE".
JKR
Here is the screenshot that I get when I try to follow your instructions.  HELP!
screenshot-unicode.jpg
Hm, that is weird, it should look like this:
properties.png
ASKER CERTIFIED SOLUTION
Avatar of sarabande
sarabande
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
HI Sara,
Thanks to you I was able to find the location of the switch and change it from Unicode to Multibyte.  Then the program would not build - giving an error MSB8031.  According to Microsoft, with VS2013, the Multibyte library was removed, and had to be installed in order to run MFC and Multibyte together.  Googling error MSB8031 gave me the link to download and install the patch.

Now I was able to build and execute my program.  The first time I ran it the program hung.  So I ran debug again.  This time it ran - giving me a page full of readable HTML.  Thanks again Sara.  You advice was on-point and enabled me to break through this roadblock.

Dave
great. i didn't know from the newer changes in vs2013 but actually the mfc way of handling UTF and foreign language support is a mess since decades. my personal conclusion is that for programs where the main target area is Europe or America you much better run with switching from MS UNICODE (which actually is UTF-16 and only the top layer of standard UNICODE) to multibyte-character set. though this actually only would support the ANSI character set, it also could be used for UTF-8 character set which contrary to UTF-16 supports full UNICODE. moreover, UTF-8 handles ASCII characters by using 1 byte, hence all ascii texts (codes 0 to 127) are 1-to-1 compatible and don't need a translation. so the combination multibyte character set + UTF-8 for foreign language texts is the key way to have a conflict-free windows application with full unicode support (if required at all). finally you only need to convince all the ms tools from 'your way' what could be done easier if you do it from beginning of a project.

Sara