emacs-devel
[Top][All Lists]
Advanced

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

Re: TUTORIAL.bg and windows-1251


From: Kenichi Handa
Subject: Re: TUTORIAL.bg and windows-1251
Date: Mon, 5 Jan 2004 13:14:39 +0900 (JST)
User-agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.3 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI)

In article <address@hidden>, Ognyan Kulev <address@hidden> writes:
> Today (2003-12-31) I've checked out emacs and tested it again. 
> Unfortunately, it doesn't work as expected -- microsoft-cp1251 font 
> encoding is not used.

> ctext-non-standard-encodings-alist contains microsoft-cp1251.

Could you try this code?

(let ((lang-env current-language-environment)
      (mirror-R (string (decode-char 'ucs #x42f)))
      (hex-print #'(lambda (head str) 
                     (insert head)
                     (dotimes (i (length str))
                       (let ((ch (aref str i)))
                         (if (< ch 128)
                             (insert ch)
                           (insert (format "\\x%X" (aref str i))))))
                     (insert "\n")))
      encoded decoded)
  (funcall hex-print "original:" mirror-R)
  (set-language-environment "Bulgarian")
  (setq encoded (encode-coding-string mirror-R 'ctext-with-extensions))
  (funcall hex-print "encoded: " encoded)
  (setq decoded (decode-coding-string encoded 'ctext-with-extensions))
  (funcall hex-print "decoded: " decoded)
  (set-language-environment "English")
  (setq encoded (encode-coding-string mirror-R 'ctext-with-extensions))
  (funcall hex-print "encoded: " encoded)
  (setq decoded (decode-coding-string encoded 'ctext-with-extensions))
  (funcall hex-print "decoded: " decoded)
  (set-language-environment lang-env))

The result I got is this.

original:\x5144F
encoded: %/1\x80\x92microsoft-cp1251\xDF
decoded: \x5144F
encoded: %G\xD0\xAF%@
decoded: \x5144F

It seems that the coding system ctext-with-extensions is
working as expected here.

> I tried to understand the code, but without great success.  So 
> ctext-pre-write-conversion seems the only place that uses 
> ctext-non-standard-encodings property of current language environment 
> (via ctext-non-standard-encodings-table).

Yes.

> Do I understand it right that 
> somehow all rendering of text to X is done via the "special" compound 
> text (ctext) coding system, while buffer can be in other coding system? 
>      If not, how this ctext coding system is used, and, consequently, 
> ctext-non-standard-encodings property?   (I just try to help getting 
> this thing working.)

Rendering is not relevant to the current problem.  When
Emacs accepts a selection request, it encodes the currently
selected text by a coding-system bound to
selection-coding-system.  By default, ctext-with-extensions
(alias of compound-text-with-extensions) is bound.  And,
`pre-write-conversion' property of ctext-with-extensions is
ctext-pre-write-conversion.  So, this function is called
before the actual encoding is done.

By the way, for rendering, I installed the code I proposed a
while ago which forces *-microsoft-cp1251 fonts to be used
for Cyrillic letters of the charset mule-unicode-0100-24ff
in Bulgarian environment on 2003-12-29.  Have you noticed
it?

---
Ken'ichi HANDA
address@hidden






reply via email to

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