CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Dec 2005
    Posts
    35

    Lightbulb wprintf doesnot print Chinese character

    When I include the following line of code in the main method,

    --------------------------------
    wprintf(L"China,in Chinese,is %s",L"中国");
    --------------------------------
    it compiles.
    At run time,it prints: "China,in Chinese,is ".
    But,I expect it prints : "China,in Chinese,is 中国".

    When I compile and run the code in another computer,
    it prints:"China,in Chinese,is 中国".
    I cannot find any difference between IDE settings and source code.

    I use WindowXP,visual studio .net 2003.

    Is there anything I should check?

    Thanks!

  2. #2
    Join Date
    Feb 2005
    Posts
    64

    Re: wprintf doesnot print Chinese character

    which OS u r using....???

    From ur ques..it seems that it might be a problem of code page u are using.....

  3. #3
    Join Date
    Jun 2005
    Location
    Tirunelveli-Tamil Nadu-India
    Posts
    354

    Smile Re: wprintf doesnot print Chinese character

    If I Helped You, "Rate This Post"

    Thanks
    Guna

  4. #4
    Join Date
    Dec 2005
    Posts
    35

    Unhappy Re: wprintf doesnot print Chinese character

    Quote Originally Posted by developerid
    which OS u r using....???

    From ur ques..it seems that it might be a problem of code page u are using.....
    I am using Window XP professional.
    All other softwares behave normally,they can show Chinese character correctly.

    I have no idea what is wrong.
    Last edited by zhang_shuigang; December 27th, 2005 at 05:11 AM.

  5. #5
    Join Date
    Dec 2005
    Posts
    35

    Re: wprintf doesnot print Chinese character

    Quote Originally Posted by Gunaamirthavelu
    Thanks.
    Sorry.I still have no idea what is wrong.

  6. #6
    Join Date
    Feb 2005
    Posts
    64

    Re: wprintf doesnot print Chinese character

    try by using MultiByteToWideChar function to convert to unicode and on both the machine, check the value of first parameter(which is code page).

    I think u might get the difference there.If the value of code page is different, than the value of codepage on m/c , on which it is not giving the correct output is wrong.

  7. #7
    Join Date
    Jun 2005
    Posts
    1,255

    Smile Re: wprintf doesnot print Chinese character

    It is not clear whether the program is running at the command prompt (as a console application, or in a DOS box), or if is running as a Win32 application. In the first case, you should check the codepage. And in both case, you should check if correct font files are installed on the computers.

  8. #8
    Join Date
    Dec 2005
    Posts
    35

    Re: wprintf doesnot print Chinese character

    Quote Originally Posted by developerid
    try by using MultiByteToWideChar function to convert to unicode and on both the machine, check the value of first parameter(which is code page).

    I think u might get the difference there.If the value of code page is different, than the value of codepage on m/c , on which it is not giving the correct output is wrong.
    Sorry,I am new to cpp.And the method MultiByteToWideChar is too complicated for me.Maybe I can try it after I am more familar with cpp.

    Thanks anyway!

  9. #9
    Join Date
    Aug 2005
    Location
    pune
    Posts
    72

    Thumbs up Re: wprintf doesnot print Chinese character

    Hi

    To Support Unicode, two things need to be done. In VC++, go to the project menu and choose settings. On the C++ tab chose the category General and add the Preprocessor Definition for _UNICODE *don’t forget the underscore* and REMOVE the _MBCS (multi-byte character set) definition. Second, under the Link tab choose the category Output and set the entry point symbol to wWinMainCRTStartup.
    This is not a requirement to display in multi-lingual applications because by default _MBCS is defined.

    plz, give the rank.

  10. #10
    Join Date
    Dec 2005
    Posts
    35

    Talking Re: wprintf doesnot print Chinese character

    Quote Originally Posted by luckykiran
    Hi

    To Support Unicode, two things need to be done. In VC++, go to the project menu and choose settings. On the C++ tab chose the category General and add the Preprocessor Definition for _UNICODE *don’t forget the underscore* and REMOVE the _MBCS (multi-byte character set) definition. Second, under the Link tab choose the category Output and set the entry point symbol to wWinMainCRTStartup.
    This is not a requirement to display in multi-lingual applications because by default _MBCS is defined.

    plz, give the rank.
    Huhu.
    I define _UNICODE,and the problem is still there.
    If I set the entry to to 'wWinMainCRTStartup',the compiler say it doesnot konw '_wWinMain@16'.

    Besides,in my code,I use unicode character(L"...") and unicode print method(wprintf) explicitly,I donot think preprocessor is to be blamed.

    Oo,maybe ...I have no idea.

  11. #11
    Join Date
    Dec 2005
    Posts
    35

    Re: wprintf doesnot print Chinese character

    I solved it.

    In Control Panel->Regional and Language Options->Regional Options ,change setting to 'English(United States)'.

    I donot know why.

    Thanks for your help!

  12. #12
    Join Date
    Jan 2006
    Posts
    1

    Cool Re: wprintf doesnot print Chinese character

    it's not solution.... problem is locale settings in CRT...

    use:
    setlocale(LC_ALL, ".OCP");

    perhaps set chinnese code page instead of ".OCP" (oem code page)

    ---------------
    HiddenGuru

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured