CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    Join Date
    Jan 2000
    Location
    India, Tamilnadu
    Posts
    279

    Question My huge project need few message box in UNICODE without UNICODE compilation?

    I have a huge old project. Converting it to total UNICODE compilation is very difficult. I need few menus and Messages boxes in UNICODE (Need in Japanese).

    How to achive this without UNICODE compilation?
    Is this possible?

    Thanks in advance
    Anita Eugene

  2. #2
    Join Date
    Jun 2003
    Location
    Armenia, Yerevan
    Posts
    720
    I think you need MessageBoxW(), wchar_t data type and maybe 'mbtowc()' and 'wctomb()'.

  3. #3
    Join Date
    Nov 2001
    Location
    Beyond Juslibol
    Posts
    1,688
    There a some unicode functions that you can call directly to its unicode implementation.

    For example TextOutW()

    There are more, probably MessageBoxW is one of them. However if you are running under Win 9x or Win Me you will need the aid of the Microsoft Layer for Unicode to run that functions. If you are running under W2000 or XP you won't need the layer for unicode and you can call all the unicode functions directly.

    TextOutW is the unique function I know that does not need the MLU. I think there are more I have seen them somewhere I can't remember now.

    Better you search MSDN for these topics.

  4. #4
    Join Date
    Jan 2000
    Location
    India, Tamilnadu
    Posts
    279

    Thanks for your replies. But... Kindly look at the four line code.

    First, thanks a lot for the replies. TextOutW(..) prints somthing but not UNICODE. (I tried with some japanese characters. I have already installed japanese characters and its working on IE)

    I tried the following code to test it for the first few characters of [Ã¥´ëºñÀÌ ÀÖÀ»±î¿ä]

    Code:
    	wchar_t wchBuff[100];
    	wchBuff[0] = 0xcc45;
    	wchBuff[1] = 0xb300;
    	wchBuff[2] = 0xbe44;
    	wchBuff[3] = 0xc774;
    	wchBuff[4] = 0x00;
    	wchBuff[5] = 0x00;
    
    	TextOutW (pCDC->m_hDC, 0,0, wchBuff, 1); 
    	MessageBoxW(NULL,wchBuff,NULL,MB_OK);
    I am on Win98. Japanese UNICODE already installed.
    What am I doing wrong?

    Thanks for the helps.
    Anita Eugene

  5. #5
    Join Date
    Nov 2001
    Location
    Beyond Juslibol
    Posts
    1,688
    First of all you are only writting one character, you should put 3 instead of 1.

    Code:
    TextOutW (pCDC->m_hDC, 0,0, wchBuff, 3);
    Second, pCDC should have selected an appropiate font for displaying japanese.

    Third, are you sure that is unicode japanese text and not shif-jis, euc or other codification?

  6. #6
    Join Date
    Jan 2000
    Location
    India, Tamilnadu
    Posts
    279

    Thanks for your reply. I tried as below

    Thankyou for your reply. I corrected as below.
    Below is a sample line cut and pasted here from my outlook

    Ã¥´ëºñÃ¥ÀÌ ÀÖÀ»±î¿ä??

    Here is my corrected code ?

    Code:
    	wchar_t wchBuff[100];
    	wchBuff[0] = 0xcc45;
    	wchBuff[1] = 0xb300;
    	wchBuff[2] = 0xbe44;
    	wchBuff[3] = 0xc774;
    	wchBuff[4] = 0x00;
    	wchBuff[5] = 0x00;
    
    	CDC *pCDC = GetDC();
    	TextOutW (pDC->m_hDC, 0,0, wchBuff, 3); 
    	MessageBoxW(NULL,wchBuff,NULL,MB_OK);
    How can I select the font ?
    What font I have to select ?


    Thanks for your helps
    Anita Eugene

  7. #7
    Join Date
    Nov 2001
    Location
    Beyond Juslibol
    Posts
    1,688
    Since you are using MFC you can create a CFont object and select it with the DC's SelectObject() function. I think you should include a valid japanese character set in the definition of the font.

    What font? Select a japanese font if you have "MS Gothic" and "MS Mincho" are examples.

    Really are those characters valid unicode japanese characters and not other codification?

    Can you tell me what do you want to write in japanese to check the wchar_t values?

  8. #8
    Join Date
    Jan 2000
    Location
    India, Tamilnadu
    Posts
    279

    Thankyou again. Here are some screenshots

    When I visited a japanese page, my IE automatically loaded japanese in to my PC and could see the page in japanese.
    I copied these lines from the webpage to my outlook as below



    then viewed the HTML of this code as below



    I converted first three characters in to hex (Ex. 52293 to 0xCC45 )
    So, I am sure these are japanese unicode bytes.

    Then I tried to print three of these characters. Please see FONT face is "Times New Roman" in my html source. But, still I see japanese.

    Code:
    	wchar_t wchBuff[100];
    	wchBuff[0] = 0xcc45;
    	wchBuff[1] = 0xb300;
    	wchBuff[2] = 0xbe44;
    	wchBuff[3] = 0xc774;
    	wchBuff[4] = 0x00;
    	wchBuff[5] = 0x00;
    
    	CDC *pDC = GetDC();
    	TextOutW (pDC->m_hDC, 0,0, wchBuff, 5); 
    	MessageBoxW(NULL,wchBuff,NULL,MB_OK);

    MS Gothic" or "MS Mincho" are not see on my font list. But, without these, I am able to see japanese in outlook and HTML page.

    I will be really thankful if you can help me little further. Let me also know how to load the font.

    Thanks again
    Anita Eugene

  9. #9
    Join Date
    Nov 2001
    Location
    Beyond Juslibol
    Posts
    1,688
    You got confused.

    Sorry but that characters are not japanese, they are corean.

  10. #10
    Join Date
    Nov 2001
    Location
    Beyond Juslibol
    Posts
    1,688
    I think these code lines can show you how to use TextOutW with japanese unicode text. The font I have used is "Arial unicode MS" which supports japanese text. You can use any other font wich supports japanese text.

    Note that in CreateFont the charset is set to 512 wich is SHIFTJIS_CHARSET, however I have tested with other values like DEFAULT_CHARSET and I continue succesfuly viewing the japanese text.
    MSDN suggest that the charset must be consistent with the facename. I'm not sure about the importance of this parameter respect the final result.

    Code:
    	CFont Font;
    	CFont *old;
    	wchar_t wchBuff[11];
    	CDC* pDC=GetDC();
    
    	Font.CreateFont(20,                            // Height
                    0,                             // Width
                    0,                             // Escapement
                    0,                             // Orientation
                    FW_BOLD,                       // Weight
                    FALSE,                         // Italic
                    FALSE,                          // Underline
                    0,                             // StrikeOut
                    512,                  // CharSet
                    OUT_DEFAULT_PRECIS,            // OutPrecision
                    CLIP_DEFAULT_PRECIS,           // ClipPrecision
                    DEFAULT_QUALITY,               // Quality
                    DEFAULT_PITCH,      // PitchAndFamily
                    _T("Arial Unicode MS"));  		// Facename
    
    	old=pDC->SelectObject(&Font);
    
    	wchBuff[0] = 0x65e5;
    	wchBuff[1] = 0x672c;
    	wchBuff[2] = 0x8a9e;
    	wchBuff[3] = 0x3067;
    	wchBuff[4] = 0x66f8;
    	wchBuff[5] = 0x304d;
    	wchBuff[6] = 0x307e;
    	wchBuff[7] = 0x3057;
    	wchBuff[8] = 0x3087;
    	wchBuff[9] = 0x3046;
    	wchBuff[10] = 0x0000;
    
    	TextOutW (pDC->m_hDC, 0,0, wchBuff, 10); 
    	pDC->SelectObject(old);
    
    	ReleaseDC(pDC);
    If the process is succesful you sould be able to see the text attached.

  11. #11
    Join Date
    Jan 2000
    Location
    India, Tamilnadu
    Posts
    279

    I think you have taken me to the final stage !!!

    You are correct. That was korean. I tried your sample as it is. But, I think the font is the problem.
    I get the following


    I am sure it is the font problem. Now, how and from where to install this font Arial Unicode MS on my PC ?

    If this font is currently not available on my PC, how is this getting displayed on my outlook or HTML ?

    How to check that I have this font on my PC?


    Thank you for your great help.

    Anita Eugene

  12. #12
    Join Date
    Nov 2001
    Location
    Beyond Juslibol
    Posts
    1,688
    I don't know why I have Arial Unicode, maybe it was installed by some application.

    Some Japanese fonts are installed when you install japanese support for your computer, for example if you download the Japanese Global IME from microsoft home page, the "MS Gothic" and "MS Mincho" fonts are installed.

    You can also search internet and try to find some japanese fonts. I think there are some free japanese fonts somewhere.

  13. #13
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940
    I think Arial Unicode MS is installed with a full install of Internet Explorer + when you add non-latin languages to your set of locales.

    I think (although I may be wrong) it comes as standard with W2K & XP but not on 98.

    That's my font of preference too as it covers just about all unicode ranges pretty thoroughly, although isn't as pretty in Arabic as Arial for instance.

    However, it is HUGE (23Mb) so I can't post it.

    You could try searching for it using google et al and get it that way.

    Darwen.

  14. #14
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940
    Oh I've just found out it comes as part of Microsoft Office so if you have that you should have it on your machine.

    Darwen.

  15. #15
    Join Date
    Nov 2001
    Location
    Beyond Juslibol
    Posts
    1,688
    Originally posted by darwen
    Oh I've just found out it comes as part of Microsoft Office so if you have that you should have it on your machine.

    Darwen.
    Thank you for the info.
    Yes I have MS Office, and many other programs. Too many, I think.

Page 1 of 2 12 LastLast

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