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.
Dave ShieldsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
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?
0
Dave ShieldsAuthor Commented:
I did not know that I could set my project settings to UNICODE!  How can I do that??
Dave
0
jkrCommented:
Open your project properties (ALT+F7), go to "Configuration Properties|C/C++|General" and change "Use Character Set" from "Multibyte" to "UNICODE".
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Dave ShieldsAuthor Commented:
JKR
Here is the screenshot that I get when I try to follow your instructions.  HELP!
screenshot-unicode.jpg
0
jkrCommented:
Hm, that is weird, it should look like this:
properties.png
0
sarabandeCommented:
Hm, that is weird

the properties are defined in 'Configuration Properties - General Page' and NOT in 'C/C++ - General Page'

i would assume that you have to turn the character set from UNICODE to MULTIBYTE (ansi) and not other way round. the vs 2003 might have used ANSI character set (especially if ported from a VC6 application) while younger visual studios have UNICODE as default.

Sara
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dave ShieldsAuthor Commented:
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
0
sarabandeCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.