all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Jason Rumney <jasonr@gnu.org>
Cc: lekktu@gmail.com, 12055@debbugs.gnu.org
Subject: bug#12055: 24.1.50; Characters "á" and "é" are not	correctly displayed on a Windows terminal
Date: Fri, 27 Jul 2012 21:03:43 +0300	[thread overview]
Message-ID: <83wr1phyio.fsf@gnu.org> (raw)
In-Reply-To: <87hastywxb.fsf@gnu.org>

> From: Jason Rumney <jasonr@gnu.org>
> Cc: lekktu@gmail.com,  12055@debbugs.gnu.org
> Date: Sat, 28 Jul 2012 00:46:08 +0800
> 
> > Well, I see some strange stuff in the input processing.
> 
> 	  /* Get the codepage to interpret this key with.  */
>           GetLocaleInfo (GetThreadLocale (),
> 			 LOCALE_IDEFAULTANSICODEPAGE, cp, 20);
> 	  cpId = atoi (cp);
> 
> is quite suspicious. It appears in two places - one is a fallback for
> older versions of Windows that do not fully support Unicode, the other
> is more interesting for this case, as it is in the dead key handling,
> and from Juanma's description, a dead key is being used to input the
> problem characters.
> 
> The above lines should probably be replaced with
> 
>    cpId = GetConsoleCP ();

Thanks.  Yes, I wondered about that as well.  However, this is not my
problem right now.  If we were decoding input with a wrong codepage, I
should have at least seen correct Unicode character codes right at
entry into key_event.  But what I see on my machine (whose ANSI
encoding is cp1255 and the corresponding OEM encoding is cp862) is
something really weird.  When I switch the keyboard to Hebrew and type
ALEPH, BET, GIMEL, whose Unicode codepoints are, respectively, u+05D0,
u+05D1, u+05D2, I see 0x0580, 0x0581, and 0x0582 instead.  That makes
no sense at all, and no amount of tinkering with input codepage can
ever fix that.

Besides, at least in my locale, the code that you mention is never
executed at all.  Instead, we return the original Unicode character
codepoint via this fragment:

      else if (event->uChar.UnicodeChar > 0)
	{
	  emacs_ev->kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
	  emacs_ev->code = event->uChar.UnicodeChar;
	}

And since, at least in my locale, event->uChar.UnicodeChar is wrong,
the rest is a logical consequence of this.

So my current theory is that it is simply wrong to look at
uChar.UnicodeChar unless we call ReadConsoleInputW, the wide-character
version of the API.  But I need data from other locales to make sure
this theory is correct.  The theory is based on the following vague
portion of the ReadConsoleInput's documentation:

  This function uses either Unicode characters or 8-bit characters
  from the console's current code page.

There isn't a word about when it does one or the other (AFAICS), which
led me to the above hypothesis, since that's the only cause that
doesn't need to be explicitly documented.

Btw, the MSDN documentation about stuff this is not as helpful as it
could have been (so what else is new?).  This page

  http://msdn.microsoft.com/en-us/library/windows/desktop/ms684166%28v=vs.85%29.aspx

says:

  uChar
      A union of the following members.

      UnicodeChar
	  Translated Unicode character.

      AsciiChar
	  Translated ASCII character.

What the heck do they mean by "translated" here?  "Translated" by whom
and how?





  reply	other threads:[~2012-07-27 18:03 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-26 12:13 bug#12055: 24.1.50; Characters "á" and "é" are not correctly displayed on a Windows terminal Dani Moncayo
2012-07-26 16:13 ` Eli Zaretskii
2012-07-26 16:24   ` Juanma Barranquero
2012-07-26 16:42     ` bug#12055: " Eli Zaretskii
2012-07-26 16:49       ` Juanma Barranquero
2012-07-26 17:18         ` bug#12055: " Eli Zaretskii
2012-07-26 18:09           ` Eli Zaretskii
2012-07-26 18:42             ` Juanma Barranquero
2012-07-26 18:29           ` Juanma Barranquero
2012-07-26 20:03             ` bug#12055: " Eli Zaretskii
2012-07-26 22:40               ` Dani Moncayo
2012-07-27  6:45                 ` bug#12055: " Eli Zaretskii
2012-07-27  8:35                   ` Dani Moncayo
2012-07-27  9:04                     ` bug#12055: " Eli Zaretskii
2012-07-27 15:12                       ` Eli Zaretskii
2012-07-27 16:46                         ` Jason Rumney
2012-07-27 18:03                           ` Eli Zaretskii [this message]
2012-07-27 18:22                             ` Eli Zaretskii
2012-07-27 23:45                         ` Juanma Barranquero
2012-07-28  1:12                         ` Dani Moncayo
2012-07-28  8:04                           ` bug#12055: " Eli Zaretskii
2012-07-28 10:06                             ` Eli Zaretskii
2012-07-28 11:55                               ` Dani Moncayo
2012-07-28 12:23                                 ` bug#12055: " Eli Zaretskii
2012-07-28 12:49                                   ` Dani Moncayo
2012-07-28 15:02                                     ` bug#12055: " Eli Zaretskii
2012-07-28 12:30                                 ` bug#12055: " Eli Zaretskii
2012-07-28 13:57                               ` Dani Moncayo
2012-07-28 16:07                                 ` Juanma Barranquero
2012-07-28 16:12                                   ` Dani Moncayo
2012-07-28 16:11                               ` Juanma Barranquero
2012-07-28 16:44                                 ` bug#12055: " Eli Zaretskii
2012-07-28 17:01                                   ` Eli Zaretskii
2012-07-26 16:44     ` Dani Moncayo
2012-07-28 14:12 ` Dani Moncayo
2012-07-28 15:01   ` bug#12055: " Eli Zaretskii
2012-07-28 15:23     ` Dani Moncayo
2012-07-28 15:34       ` Dani Moncayo
2012-07-28 16:27         ` bug#12055: " Eli Zaretskii
2012-07-28 15:35       ` Eli Zaretskii
2012-07-28 15:46         ` Dani Moncayo

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

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

  git send-email \
    --in-reply-to=83wr1phyio.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=12055@debbugs.gnu.org \
    --cc=jasonr@gnu.org \
    --cc=lekktu@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.