bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Kazuhiro Ito
Subject: bug#12693: 24.2.50; src/w32font.c should depend on ANSI code page
Date: Tue, 23 Oct 2012 22:05:46 +0900
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (Gojō) APEL/10.8 EasyPG/1.0.0 Emacs/24.2.50 (i386-mingw-nt6.1.7601) MULE/6.0 (HANACHIRUSATO)

> > When I run Emacs on Cygwin with the native Windows UI, I can't specify
> > font by non-ascii font name.  For example, the below code success on
> > precompiled binary on Windows (Japanese edition) but raises error on
> > Cygwin with the native Windows UI.
> >
> > (set-default-font "MS ゴシック-14")
> >
> > The reason is that lfFaceName member of LOGFONT structure is expected
> > to be encoded in ANSI code page, but Emacs encodes in or decodes as
> > the coding system specified in locale-coding-system variable.  It is
> > set to utf-8-unix on Cygwin and causes the above problem.
> 
> This is a problem with the Cygwin build's initialisation of
> locale-coding-system. It is supposed to be set to the coding system that
> system calls will accept, which on Windows cannot be utf-8 (maybe on
> recent versions it can be, but when I tried on Windows XP, it caused all
> manner of problems).

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


And, some functions expect locale-coding-system to be set locale's
coding system, not ANSI code page.
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")))

-> (utf-8-unix "2012年10月23日 21時30分39秒" #("2012蟷エ10譛\21023譌・ 
21譎\20230蛻\20639遘\222" 4 5 (charset cp932-2-byte) 5 8 (charset katakana-sjis) 8 
13 (charset cp932-2-byte) 13 17 (charset katakana-sjis) 17 26 (charset 
cp932-2-byte)))


At present, locale-coding-system has to be ANSI code page for
(w32-select-font), and has to be locale's coding system for
(format-time-string "%c").  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).

-- 
Kazuhiro Ito

reply via email to

[Prev in Thread] Current Thread [Next in Thread]