reading and writing xml with Chinese C/C++
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: reading and writing xml with Chinese C/C++

  1. #1
    Join Date
    May 2014
    Posts
    1

    reading and writing xml with Chinese C/C++

    Currently I'm working on a application which reads the input from the server and write to a file.

    Message stored in server : idle_message="维杰PC时钟" key_prompt="在按键"

    1. Server is sending a xml reply with encode type as "UTF-8". In my code I'm store in a char array.

    [ char * ch = "idle_message="缁存澃PC鏃堕挓" key_prompt="鍦ㄦ寜閿" msg came from server and copied from vs2005 watch point]

    2. After this I'm writing the same to a file in my desk using the API WriteFile. When i open the file in Editplus below is the content.

    idle_message="维杰PC时钟" key_prompt="在按键"

    3. Again I'm trying to read the file and storing into the char array. Below is the content viewed by the watchpoint in VS2005.

    idle_message="缁存澃PC鏃堕挓" key_prompt="鍦ㄦ寜閿?

    I'm trying to find the starting and ending chinese char and I'm converting that char to wchar_t using the API mcstowcs() for display, its coming as completely junk chars.

    I can able to every place the chinese char are different.
    Now kindly help how to overcome this problem.

    Message from server is same which is written into the file. When I view in VS2005, it looks different and after the mcstowcs(), I'm not getting the correct message which I want.

    Thanks

    Vijay

  2. #2
    Join Date
    Nov 2003
    Posts
    1,822

    Re: reading and writing xml with Chinese C/C++

    >> I'm converting that char to wchar_t using the API mcstowcs() for display
    No.

    You want to convert UTF-8 to UTF-16. mcstowcs() does not do this. Here is a function that does: http://forums.codeguru.com/showthrea...31#post1790131

    >> Below is the content viewed by the watchpoint in VS2005.
    UTF8 text may not look correct because the IDE doesn't assume that it is encoded as UTF8. Once you convert it to a wchar_t string correctly, the IDE should render that text correctly.

    gg

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center