|
|
|
date: Sat, 31 May 2008 22:14:00 -0700,
group: microsoft.public.win32.programmer.ui
back
Re: WM_CHAR Unicode and Code Page
Thanks for your reply. I am in my own process of conversion to Unicode,
thanks anyway.
I understand now and can make WM_CHAR give me unicodes by make creating the
window as wide, thanks.
However, what I need to do is get both a code page character value AND a
unicode character value. How can I do that?
Also, is there a way to get a Unicode in a window without the window being
created as wide?
Specific answers would be greatly appreciated.
Thankyou,
Tony Duff
"Mihai N." wrote:
> > I need to get code page value for the char AND the unicode value (I need
> > UTF16) in one shot, where that is possible. How can I do that?
>
> You can't.
>
> The windows should be Unicode in order to receive Unicode messages.
>
> Using RegisterClassW (or RegisterClassExW) is enough for Windows to believe
> that your window is Unicode (returning TRUE for IsWindowUnicode).
>
> But is not enough for all things to work right.
> You also need to create the window as Unicode
> (using CreateWindowW or CreateWindowExW) and
> "clean the message pump" (using GetMessageW, DispatchMessageW and
> DefWindowProcW)
>
> Overall, maintaining a mixed application is a major pain.
> Moving to Unicode all the way (compiling with UNICODE and _UNICODE)
> pays back fast enough to justify the effort.
>
> The task looks more difficult than it really is.
> You can start from here:
> http://www.mihai-nita.net/article.php?artID=tounicode
>
>
>
> --
> Mihai Nita [Microsoft MVP, Visual C++]
> http://www.mihai-nita.net
> ------------------------------------------
> Replace _year_ with _ to get the real email
>
date: Sun, 1 Jun 2008 02:39:00 -0700
author: Tony Duff
Re: WM_CHAR Unicode and Code Page
Thanks.
I have the window unicoded and successfully get unicodes. However, I am
having trouble converting them to ANSI codes.
I have used WideCharToMultiByte.
I am on a US Windows XP system with both US and Russian keyboards installed.
I change to the russian keyboard, input a character and run it through
WideCharToMultiByte.
If I explicitly give 1251 (russian ANSI codepage) for the first param of
WideCharToMultiByte, the conversion from the unicode to the single byte char
happens perfectly well. If I try anything else, including the default
option for WideCharToMultiByte and also the current thread ACP option, it
sends me back the default character for couldn't convert, a question mark.
I have read all the keyboard documentation and tried everything available to
try to get the CP for the russian keyboard when it is active but everything
returns the US OEM ANSI code.
What am I doing wrong? Or, more explicitly, I not only need the
WideCharToMultiByte function but I also need the current keyboards ANSI code
page. How do I get both?
Tony Duff
"Mihai N." wrote:
>
> > However, what I need to do is get both a code page character value AND a
> > unicode character value. How can I do that?
>
> Once you get the Unicode value, you can convert it to what you want
> by using WideCharToMultiByte
>
>
> > Also, is there a way to get a Unicode in a window without the window being
> > created as wide?
>
> Technically, not the CreateWindow matters, is RegisterClass that's important.
> If you use RegisterClassW with CreateWindowA, Windows will still report true
> for IsWindowUnicode.
> But if the "message pump is not clean" you end up with all kind of surprises.
> It's asking for future trouble :-)
>
>
> --
> Mihai Nita [Microsoft MVP, Visual C++]
> http://www.mihai-nita.net
> ------------------------------------------
> Replace _year_ with _ to get the real email
>
date: Mon, 2 Jun 2008 01:36:00 -0700
author: Tony Duff
Re: WM_CHAR Unicode and Code Page
OK, thanks, I have that working now.
Next comes logical font creation.
1) As I see it, logfont API's belong to the code page era. Is there
something new for unicode that I have missed?
2) Specifically, logfonts demand a code page be provided. Is there a
generic code page number that will produce a logfont from a specified font
that will have all unicode glyphs that are in the font in the logfont?
Thanks,
Tony Duff
"Mihai N." wrote:
> > What am I doing wrong? Or, more explicitly, I not only need the
> > WideCharToMultiByte function but I also need the current keyboards
> > ANSI code page. How do I get both?
>
> Working with the code page matching the keyboard is problematic.
> It is not unicode, and it is not ANSI (the current system code page).
> So most of the APIs will handle that wrong.
>
> But if you are sure this is what you need:
> 1. GetKeyboardLayout
> "The low word contains a Language Identifier for the input language
> and the high word contains a device handle to the physical layout
> of the keyboard"
> 2. Make a LCID using MAKELCID( theKbdLangIdentifier, SORT_DEFAULT )
> (the sort part does not affect the ansi code page)
> 3. Use GetLocaleInfo( lcid, LOCALE_IDEFAULTANSICODEPAGE, ... )
> to get the ANSI code page matching the keyboard locale
>
>
> --
> Mihai Nita [Microsoft MVP, Visual C++]
> http://www.mihai-nita.net
> ------------------------------------------
> Replace _year_ with _ to get the real email
>
date: Wed, 4 Jun 2008 19:45:00 -0700
author: Tony Duff
|
|