GNU bug report logs - #23814
24.5; bug of hz coding-system

Previous Next

Package: emacs;

Reported by: ynyaaa <at> gmail.com

Date: Tue, 21 Jun 2016 12:23:02 UTC

Severity: normal

Found in version 24.5

Fixed in version 26.1

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #26 received at 23814 <at> debbugs.gnu.org (full text, mbox):

From: handa <handa <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: ynyaaa <at> gmail.com, 23814 <at> debbugs.gnu.org
Subject: Re: bug#23814: 24.5; bug of hz coding-system
Date: Wed, 13 Jul 2016 23:12:47 +0900
In article <83d1mngirw.fsf <at> gnu.org>, Eli Zaretskii <eliz <at> gnu.org> writes:

> Ping!  Could you please comment on this issue?

Sorry, I've overlooked that mail.

> > > >> `encode-hz-region' uses `iso-2022-7bit' coding-system internally,
> > > >> replacing it with the coding-system below will work.
> > > >> 
> > > >> (define-coding-system 'iso-2022-cn-gb
> > > >>   "ISO 2022 based 7bit encoding only for Chinese GB2312."
> > > >>   :coding-type 'iso-2022
> > > >>   :mnemonic ?C
> > > >>   :charset-list '(ascii chinese-gb2312)
> > > >>   :designation [(ascii chinese-gb2312) nil nil nil]
> > > >>   :flags '(ascii-at-eol ascii-at-cntl designation 7-bit safe)
> > > >>   )

Right.  But, as there are already so many iso-2022 based coding systems,
I'd like to avoid adding a new one just for encode-hz-region.  I think
the attached patch is sufficent.  Could you please try it?  It also
fixes the problem of incorrect decoding of "~{7~~}".

---
K. Handa
handa <at> gnu.org

diff --git a/lisp/language/china-util.el b/lisp/language/china-util.el
index e531640..9735bd6 100644
--- a/lisp/language/china-util.el
+++ b/lisp/language/china-util.el
@@ -95,7 +95,9 @@ decode-hz-region
 	(goto-char (point-min))
 	(while (search-forward "~" nil t)
 	  (setq ch (following-char))
-	  (if (or (= ch ?\n) (= ch ?~)) (delete-char -1)))
+          (if (= ch ?{)
+              (search-forward "~}" nil 'move)
+            (if (or (= ch ?\n) (= ch ?~)) (delete-char -1))))
 
 	;; "^zW...\n" -> Chinese GB2312
 	;; "~{...~}"  -> Chinese GB2312
@@ -141,7 +143,7 @@ encode-hz-region
   (save-excursion
     (save-restriction
       (narrow-to-region beg end)
-
+      (put-text-property beg end 'charset 'chinese-gb2312)
       ;; "~" -> "~~"
       (goto-char (point-min))
       (while (search-forward "~" nil t)	(insert ?~))





This bug report was last modified 8 years and 85 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.