From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Sergey Vnotchenko Newsgroups: gmane.emacs.bugs Subject: Russian copy & paste failed under X11 (from emacs to kde/gnome) Date: Thu, 12 Aug 2004 20:49:24 +0400 Organization: Informika Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: <411B9F94.5090900@informika.ru> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2037912108==" X-Trace: sea.gmane.org 1092329407 12480 80.91.224.253 (12 Aug 2004 16:50:07 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 12 Aug 2004 16:50:07 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 12 18:49:55 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BvIm2-0001Ft-00 for ; Thu, 12 Aug 2004 18:49:54 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BvIpw-0003P4-Qw for geb-bug-gnu-emacs@m.gmane.org; Thu, 12 Aug 2004 12:53:56 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BvIpu-0003O2-DE for bug-gnu-emacs@gnu.org; Thu, 12 Aug 2004 12:53:54 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BvIpq-0003Hg-Qy for bug-gnu-emacs@gnu.org; Thu, 12 Aug 2004 12:53:54 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BvIpq-0003HQ-LX for bug-gnu-emacs@gnu.org; Thu, 12 Aug 2004 12:53:50 -0400 Original-Received: from [80.250.175.22] (helo=shine.inf) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BvIls-0005pV-Pm for bug-gnu-emacs@gnu.org; Thu, 12 Aug 2004 12:49:45 -0400 Original-Received: from informika.ru (localhost [127.0.0.1]) by shine.inf (Postfix) with ESMTP id B8D7D8756 for ; Thu, 12 Aug 2004 20:49:25 +0400 (MSD) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040114 X-Accept-Language: ru, en Original-To: bug-gnu-emacs@gnu.org X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:8687 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:8687 This is a multi-part message in MIME format. --===============2037912108== Content-Type: multipart/alternative; boundary="------------050206060201090403030902" This is a multi-part message in MIME format. --------------050206060201090403030902 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit From: Sergey Vnotchenko To: bug-gnu-emacs@gnu.org Subject: Russian copy & paste failed under X11 (from emacs to kde/gnome) This bug report will be sent to the Free Software Foundation, not to your local site managers! Please write in English, because the Emacs maintainers do not have translators to read other languages for them. Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list, and to the gnu.emacs.bug news group. In GNU Emacs 21.3.1 (i586-suse-linux, X toolkit, Xaw3d scroll bars) of 2004-04-06 on gray configured using `configure '--with-gcc' '--with-pop' '--with-system-malloc' '--prefix=/usr' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--with-x' '--with-xpm' '--with-jpeg' '--with-tiff' '--with-gif' '--with-png' '--with-x-toolkit=lucid' '--x-includes=/usr/X11R6/include' '--x-libraries=/usr/X11R6/lib' 'i586-suse-linux' 'CC=gcc' 'CFLAGS=-O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -pipe -DSYSTEM_PURESIZE_EXTRA=25000 -DSITELOAD_PURESIZE_EXTRA=10000 -D_GNU_SOURCE ' 'LDFLAGS=-s' 'build_alias=i586-suse-linux' 'host_alias=i586-suse-linux' 'target_alias=i586-suse-linux'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: C value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: C value of $LANG: ru_RU.KOI8-R locale-coding-system: cyrillic-koi8 default-enable-multibyte-characters: t Please describe exactly what actions triggered the bug and the precise symptoms of the bug: HOW TO REPRODUCE: 1) Select text with russian characters. 2) Paste in Mozilla browser. Result - no russian, only ascii chars appears. 3) Paste in any KDE app. Result - incorrect russian chars appears. ANALYSIS: I've traced problem down to 'ctext-pre-write-conversion' defun, which failed to provide correct conversion. I've hacked it to convert selection directly to koi8 and append neccessary escape sequences. So, it is now seems to works for koi, but surely broken for other encodings. With best regards, Sergey. ;; WORKAROUND (FOR KOI8 AND ASCII ONLY): (defun ctext-pre-write-conversion (from to) "Encode characters between FROM and TO as Compound Text w/Extended Segments. If FROM is a string, or if the current buffer is not the one set up for us by run_pre_post_conversion_on_str, generate a new temp buffer, insert the text, and convert it in the temporary buffer. Otherwise, convert in-place." (cond ((and (string= (buffer-name) " *code-converting-work*") (not (stringp from))) ; Minimize consing due to subsequent insertions and deletions. (buffer-disable-undo) (narrow-to-region from to)) (t (let ((buf (current-buffer))) (set-buffer (generate-new-buffer " *temp")) (buffer-disable-undo) (if (stringp from) (insert from) (insert-buffer-substring buf from to)) (setq from (point-min) to (point-max))))) (encode-coding-region from to 'cyrillic-koi8-unix) ;; Convert clipboard to extended segment (koi8-r) ;; according to http://www.xfree86.org/current/ctext.pdf ;; (Non-Standard Character Set Encodings) (save-match-data (goto-char (point-min)) (setq case-fold-search nil) (while (re-search-forward "[^[:ascii:]]\\{1,16383\\}" nil 'move) (forward-char) (setq text (match-string 0) length (+ (length text) 7) M (+ (/ length 128) 128) L (+ (% length 128) 128) ext_segment (concat "\x1b\x25\x2f\x31" (vector M L) "koi8-r\x2" text) ) (replace-match ext_segment) ) ) nil) --------------050206060201090403030902 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit
From: Sergey Vnotchenko <sergey@shine.inf>
To: bug-gnu-emacs@gnu.org
Subject: Russian copy & paste failed under X11 (from emacs to kde/gnome) 

This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English, because the Emacs maintainers do not have
translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.

In GNU Emacs 21.3.1 (i586-suse-linux, X toolkit, Xaw3d scroll bars)
 of 2004-04-06 on gray
configured using `configure '--with-gcc' '--with-pop' '--with-system-malloc' '--prefix=/usr' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--with-x' '--with-xpm' '--with-jpeg' '--with-tiff' '--with-gif' '--with-png' '--with-x-toolkit=lucid' '--x-includes=/usr/X11R6/include' '--x-libraries=/usr/X11R6/lib' 'i586-suse-linux' 'CC=gcc' 'CFLAGS=-O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -pipe 	 -DSYSTEM_PURESIZE_EXTRA=25000 	 -DSITELOAD_PURESIZE_EXTRA=10000 	 -D_GNU_SOURCE ' 'LDFLAGS=-s' 'build_alias=i586-suse-linux' 'host_alias=i586-suse-linux' 'target_alias=i586-suse-linux''
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: C
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: C
  value of $LANG: ru_RU.KOI8-R
  locale-coding-system: cyrillic-koi8
  default-enable-multibyte-characters: t

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

HOW TO REPRODUCE:
1) Select text with russian characters.
2) Paste in Mozilla browser. Result - no russian, only ascii chars appears.
3) Paste in any KDE app. Result - incorrect russian chars appears.

ANALYSIS:
I've traced problem down to 'ctext-pre-write-conversion' defun, which failed
to provide correct conversion. I've hacked it to convert selection directly
to koi8 and append neccessary escape sequences. So, it is now seems to works 
for koi, but surely broken for other encodings.

With best regards, Sergey.

;; WORKAROUND (FOR KOI8 AND ASCII ONLY):

(defun ctext-pre-write-conversion (from to)
  "Encode characters between FROM and TO as Compound Text w/Extended Segments.

If FROM is a string, or if the current buffer is not the one set up for us
by run_pre_post_conversion_on_str, generate a new temp buffer, insert the
text, and convert it in the temporary buffer.  Otherwise, convert in-place."
  (cond ((and (string= (buffer-name) " *code-converting-work*")
	      (not (stringp from)))
	 ; Minimize consing due to subsequent insertions and deletions.
	 (buffer-disable-undo)
	 (narrow-to-region from to))
	(t
	 (let ((buf (current-buffer)))
	   (set-buffer (generate-new-buffer " *temp"))
	   (buffer-disable-undo)
	   (if (stringp from)
	       (insert from)
	     (insert-buffer-substring buf from to))
	   (setq from (point-min) to (point-max)))))
  (encode-coding-region from to 'cyrillic-koi8-unix)
  ;; Convert clipboard to extended segment (koi8-r)
  ;; according to http://www.xfree86.org/current/ctext.pdf
  ;; (Non-Standard Character Set Encodings)
  (save-match-data
    (goto-char (point-min))
    (setq case-fold-search nil)
    (while (re-search-forward "[^[:ascii:]]\\{1,16383\\}" nil 'move)
      (forward-char)
      (setq 
       text (match-string 0)
       length (+ (length text) 7)
       M (+ (/ length 128) 128)
       L (+ (% length 128) 128)
       ext_segment (concat "\x1b\x25\x2f\x31" (vector M L) "koi8-r\x2" text)
       )
      (replace-match ext_segment)
      )
    )
      
  nil)

--------------050206060201090403030902-- --===============2037912108== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Bug-gnu-emacs mailing list Bug-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs --===============2037912108==--