Win32 console's MSXML reading Chinese problem solving process

xiaoxiao2021-03-06  49

A few days ago, a program that parsing XML is required in the program, so I started learning.

Previously, Java-based Xerces based on Apache was previously used on the Solaris platform. It should be not a problem. This time is developed on Windows, so I am ready to use MSXML. First

Www.microsoft.com Download a MSXML SDK 4.0 SP2. After installation, follow the Help file (Visual C Win32 Console program), run successfully. Then I started reading my own XML file, dumbful, Chinese attribute can't read it! Track the contentHandler of SAX2, read the character length of the character's getValue returned to 2, just a "good!

First of all, I think that it may be an encoding problem, using XMLSPY 2005 to adjust Encoding to GB2312, UTF-8, UTF-16, UCS-2, etc., can't!

Then I will change the project to Unicode, and I can't! It is not possible to save the MBCs.

In the third step, I got a Microsoft's Chinese website, I got a msxmlchs.msi Chinese version, installation, and problem still!

In the fourth step, download Xerces C, compile SAX2PRINT in Examples, read Chinese, but need a conversion class, feel and MFC combination

Not very good (maybe I am not familiar with Xerces C), although the work.

Step 5, use the DOM model, or you can't read Chinese!

The sixth, using Smart Pointer DOM, finally can read Chinese, but I still want to find DOM and SAX2 can't read Chinese.

Finally, I found some information on the Internet, I finally figured out the reason, to call setLocale (lc_all, "chinese-simplified). It seems that the C language is not clearance.

There is not so much trouble in the MFC application, you can use it directly

转载请注明原文地址:https://www.9cbs.com/read-82109.html

New Post(0)