Subject: bug#12693: 24.2.50; src/w32font.c should depend on ANSI code page

From: Eli Zaretskii <[email-masked]>
Date: Tue, 23 Oct 2012 18:22:17 +0200

> Date: Tue, 23 Oct 2012 22:05:46 +0900
> From: Kazuhiro Ito <[email-masked]>
> Cc: [email-masked]
> 
> On Cygwin, locale-coding-system's value depends on its environment.
> For example,
> 
> $ env LANG=ja_JP.CP932 emacs --batch --eval '(princ locale-coding-system)'
> -> japanese-cp932-unix
> 
> $ env LANG=ja_JP.UTF-8 emacs --batch --eval '(princ locale-coding-system)'
> -> utf-8-unix

This is not necessarily relevant to Emacs, or at least doesn't provide
a definitive answer to the question what encoding should ENCODE_SYSTEM
use in the cygw32 build, which is a kind of androgen wrt encoding and
decoding issues.

There are several places where this issue might (or will) pop up:

  . decoding keyboard key events
  . encoding and decoding file names
  . encoding strings passed to various non-file APIs, like the one you
    mentioned

At least the first 2 items use different single-byte encoding in the
GUI and the console frames.

Someone(TM) should analyze all these and come up with recommendations
whether cygw32 should cater to the normal Cygwin locale, or maybe for
practical reasons it should do something else.

> Please try the below code (cygwin, locale is ja_JP.UTF-8).
> 
> (list
>  locale-coding-system
>  (let ((locale-coding-system 'utf-8))
>    (format-time-string "%c"))
>  (let ((locale-coding-system 'cp932))
>    (format-time-string "%c")))

This is but one example.  As you yourself found out, this encoding is
unsuitable for the font interface.

> At present, locale-coding-system has to be ANSI code page for
> (w32-select-font)

So maybe we need w32-select-font to use UTF-16 in the cygw32 case, as
it does for menus.

> The cause is that we use two kinds of system calls, Windows's API
> and Cygwin's API (may three, if we count Windows's Unicode API).

See above: there's much more than just 3.