Subject: Re: Cyrillic mode under NT Emacs

From: Andrew Innes <[email-masked]>
Date: Tue, 2 Sep 1997 16:01:19 +0100 (BST)

On Thu, 28 Aug 1997 17:28:04 -0400, "Kevin D'Elia" <[email-masked]> said:
>Hello,
>
>    I've seen this question answered before, so I'm hoping that someone
>can help me with it now.  I have input locale set to Russian and I can
>type Cyrillic characters in WordPad, NotePad, etc.  But Emacs displays
>???s.  What do I have to set in my .emacs to allow the entry of
>Cyrillic?  I am using 34.1.  Thanks in advance to all who respond...

As I understand it, this problem stems from the fact that you are
running on a non-Russian version of Windows (so the default locale does
not use a codepage that contains Cyrillic characters).  Although you can
select a Russian keyboard layout, Emacs cannot receive those characters
because it is expecting characters in the default ANSI codepage for the
system locale.

As a temporary measure, you can try changing the system locale in the
Regional Settings section of Control Panel.  I haven't tried this
myself, but it should allow Emacs to receive Cyrillic characters.

As a start towards providing a proper fix, I've added some basic support
functions to 19.34.5 to allow inspecting and changing the locale Emacs
operates in (independent of the system locale).  The functions are

  win32-set-current-locale
  win32-get-default-locale-id
  win32-get-current-locale-id
  win32-get-locale-info

Unfortunately I was rather rushed at the time, so I didn't have time to
implement the rather useful function `win32-locale-ids', which would
return a list of the supported locale-ids.  If 19.34.5 hasn't been
released yet (I gather not) then I'll get that added for the release -
it will then be possible to knock up some simple lisp functions to allow
the user to select the desired locale using either the standard three
letter language/region codes, or the long name form supported by
Windows.

To give a taste of what it to come, I've appended a small bit of lisp I
knocked up to test this.  You can call win32-list-locales to find out
the locale id (LCID - a 16-bit number) for the locale you want to use,
and then put (win32-set-current-locale LCID) in your .emacs if you want
to use that locale all the time.

I would appreciate it if someone could test this, to verify that you can
indeed enter Cyrillic characters (for instance) using the Russian
keyboard layout once you've set the locale to 1049 (the id for Russian).

Thanks,
AndrewI

-----------------------------------------------------------------
(defvar win32-known-locales nil
  "List of locale ids known to be supported.")

(defun win32-locale-ids ()
  "Return list of all supported locale ids."
  (let ((i 65535)
	locales)
    (while (> i 0)
      (if (win32-get-locale-info i)
	  (setq locales (cons i locales)))
      (setq i (1- i)))
    locales))

(defun win32-list-locales ()
  "List the supported locales."
  (interactive)
  (if (null win32-known-locales)
      (setq win32-known-locales (win32-locale-ids)))
  (switch-to-buffer-other-window (get-buffer-create "*Locales*"))
  (erase-buffer)
  (insert "Known locales:\n\nLCID\tShort\tLong\n\n")
  (insert (mapconcat
	   '(lambda (x)
	      (format "%d\t%s\t%s"
		      x
		      (win32-get-locale-info x)
		      (win32-get-locale-info x t)))
	   win32-known-locales "\n"))
  (insert "\n")
  (goto-char (point-min)))
-----------------------------------------------------------------

AndrewI