From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: handa Newsgroups: gmane.emacs.bugs Subject: bug#23814: 24.5; bug of hz coding-system Date: Wed, 13 Jul 2016 23:12:47 +0900 Message-ID: <87wpkphbj4.fsf@gnu.org> References: <877fdiu3xz.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1468419334 1635 80.91.229.3 (13 Jul 2016 14:15:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 13 Jul 2016 14:15:34 +0000 (UTC) Cc: ynyaaa@gmail.com, 23814@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 13 16:15:22 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bNKwa-0000Yv-SN for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Jul 2016 16:15:21 +0200 Original-Received: from localhost ([::1]:47901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNKwZ-00023w-VQ for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Jul 2016 10:15:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNKvQ-0008JU-H2 for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 10:14:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNKvK-00061I-8W for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 10:14:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37569) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNKvK-00061C-5S for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 10:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bNKvJ-0002gT-Vo for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 10:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: handa Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Jul 2016 14:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23814 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23814-submit@debbugs.gnu.org id=B23814.146841919910260 (code B ref 23814); Wed, 13 Jul 2016 14:14:01 +0000 Original-Received: (at 23814) by debbugs.gnu.org; 13 Jul 2016 14:13:19 +0000 Original-Received: from localhost ([127.0.0.1]:49905 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNKuZ-0002fL-A1 for submit@debbugs.gnu.org; Wed, 13 Jul 2016 10:13:19 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:48065) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNKuT-0002f2-6X for 23814@debbugs.gnu.org; Wed, 13 Jul 2016 10:13:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNKuM-0005rV-Tu for 23814@debbugs.gnu.org; Wed, 13 Jul 2016 10:13:03 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:54948) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNKuH-0005r0-6N; Wed, 13 Jul 2016 10:12:57 -0400 Original-Received: from fl1-61-203-105-252.iba.mesh.ad.jp ([61.203.105.252]:53558 helo=shatin) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bNKuF-00073D-2s; Wed, 13 Jul 2016 10:12:55 -0400 Original-Received: from handa by shatin with local (Exim 4.86_2) (envelope-from ) id 1bNKu8-00057x-00; Wed, 13 Jul 2016 23:12:48 +0900 In-Reply-To: <83d1mngirw.fsf@gnu.org> (message from Eli Zaretskii on Sat, 09 Jul 2016 14:20:19 +0300) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org 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 Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:120989 Archived-At: In article <83d1mngirw.fsf@gnu.org>, Eli Zaretskii 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@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 ?~))