unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Joakim Hårsman" <joakim.harsman@gmail.com>
Cc: 10299@debbugs.gnu.org
Subject: bug#10299: Emacs doesn't handle Unicode characters in keyboard layout on MS Windows
Date: Sat, 17 Dec 2011 17:23:36 +0200	[thread overview]
Message-ID: <831us31atj.fsf@gnu.org> (raw)
In-Reply-To: <CAFJF9wXzbbT=8hcJoU3Vi8GZSukxt_CE_2_eHiqgbJFzC=Nnhw@mail.gmail.com>

> Date: Sat, 17 Dec 2011 13:52:29 +0100
> From: Joakim Hårsman <joakim.harsman@gmail.com>
> Cc: 10299@debbugs.gnu.org
> 
> I had to switch to iswalpha because isalpha segfaulted when sent
> values larger than 255. wParam isn't really the Unicode code point
> here either, it's encoded as UTF-16. With this change, Emacs no longer
> prints a question mark when I press the special keys, it doesn't print
> anything at all.
> 
> I figured this is beacause wParam isn't a valid Unicode codepoint
> here, like it is when you get a WM_UNICHAR, so I tried a quick hack
> converting from UTF-16 and re-posting as a WM_UNICHAR even. I changed
> the handling of WM_CHAR in w32_wnd_proc:
> 
>     case WM_CHAR:
>       if (wParam > 255 )
>         {
>           /* Hacky conversion from UTF-16 to UCS-4.
>              Doesn't handle surrogate pairs. */
>           unsigned short lo = wParam & 0x0000FFFF;
>           unsigned short hi = (wParam & 0xFFFF0000) >> 8;
>           wParam  = hi | lo;
> 
>           W32Msg wmsg;
>           wmsg.dwModifiers = w32_get_key_modifiers (wParam, lParam);
>           signal_user_input ();
>           my_post_msg (&wmsg, hwnd, WM_UNICHAR, wParam, lParam);
> 
>         }
>       else
>         post_character_message (hwnd, msg, wParam, lParam,
>                                 w32_get_key_modifiers (wParam, lParam));
> 
> This fixed it! I can now enter the characters with a custom keyboard
> layout so I'm happy.

That's good news.  However, I'm puzzled: are you saying that the code
points passed by Windows to Emacs for the characters generated by MKLC
are outside the Unicode BMP, i.e. larger than 65535?  If so, what code
points are they?

> There's loads of bugs still (e.g. the frame title
> is "e" instead of "Emacs@host" because I just pass the frame's namebuf
> to CreateWindowW without converting it to a wide string), but at least
> the main issue is fixed.

If at all possible, I'd like to keep the use of wide APIs to the
absolute minimum, because:

> I guess these changes need to only happen when running on NT for Emacs
> to still work on Windows 95 or does Emacs use MSLU?

We do use MSLU on Windows 9X (because the display routines need
that).  However, given that none of the developers has easy access to
a 9X machine, it is very easy to break Emacs on 9X by excess usage of
wide APIs.  In fact, all versions of Emacs 23 didn't work on Windows
9X and only recently we were lucky enough to find a 9X user who helped
us debug the problems and fix them.

So if possible, could you perhaps try finding out why you didn't get
UTF-16 codepoints without CreateWindowW and GetMessageW?  Maybe it's
TranslateMessage that causes that, and the original message Emacs gets
is okay?

> Maybe they should depend on some lisp variable being set?

Probably just on the value of os_subtype.

> Here's my changes in full so far:

Thanks.

This will probably need to wait until after v24.1 is released.






  reply	other threads:[~2011-12-17 15:23 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-14 20:39 bug#10299: Emacs doesn't handle Unicode characters in keyboard layout on MS Windows Joakim Hårsman
2011-12-15  6:22 ` Eli Zaretskii
2011-12-15  6:51   ` Kenichi Handa
2011-12-15  7:53   ` Joakim Hårsman
2011-12-15 10:52     ` Eli Zaretskii
2011-12-15 11:11       ` Joakim Hårsman
2011-12-15 13:16         ` Eli Zaretskii
2011-12-15 14:40   ` Jason Rumney
2011-12-15 15:08     ` Lennart Borgman
2011-12-15 15:40     ` Joakim Hårsman
2011-12-15 17:34     ` Eli Zaretskii
2011-12-15 20:50       ` Joakim Hårsman
2011-12-15 21:47         ` Joakim Hårsman
2011-12-16  8:13           ` Eli Zaretskii
2011-12-16 11:01             ` Joakim Hårsman
2011-12-16 11:14               ` Dani Moncayo
2011-12-16 11:26                 ` Eli Zaretskii
2011-12-17 12:52                   ` Joakim Hårsman
2011-12-17 15:23                     ` Eli Zaretskii [this message]
     [not found]                       ` <CAFJF9wW7Cfmad+BmjQ4A-sVeLi+eRvOXSWfD=--=QJmr3Ver6w@mail.gmail.com>
2011-12-18 18:13                         ` Eli Zaretskii
2011-12-19 10:44                           ` Joakim Hårsman
2011-12-19 10:59                             ` Lennart Borgman
2011-12-19 11:04                               ` Joakim Hårsman
2011-12-19 11:17                                 ` Lennart Borgman
2011-12-19 11:50                                   ` Joakim Hårsman
2011-12-19 13:31                           ` Jason Rumney
2011-12-20 21:16                           ` Joakim Hårsman
2012-01-14 16:40                             ` Joakim Hårsman
2012-01-16 14:03                               ` Stefan Monnier
2012-01-23 19:15                                 ` Joakim Hårsman
2012-01-24  1:35                                   ` Stefan Monnier
2012-01-24  9:40                                     ` Andreas Schwab
2012-01-24 12:03                                       ` Juanma Barranquero
2012-01-24 20:42                                         ` Joakim Hårsman
2012-07-28 14:50                                           ` Eli Zaretskii
2012-08-06 20:20                                             ` Joakim Hårsman
2012-08-07  2:53                                               ` Eli Zaretskii
2012-08-07 19:47                                                 ` Joakim Hårsman
2012-08-08  2:48                                                   ` Eli Zaretskii
2012-08-08 18:54                                                     ` Joakim Hårsman
2012-08-10  6:56                                                       ` Eli Zaretskii
2012-08-07 12:15                                               ` Jason Rumney
2012-08-07 19:49                                                 ` Joakim Hårsman
2011-12-16 11:22               ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=831us31atj.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=10299@debbugs.gnu.org \
    --cc=joakim.harsman@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).