From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#23814: 24.5; bug of hz coding-system Date: Sat, 23 Jul 2016 20:47:27 +0300 Message-ID: <83eg6kutzk.fsf@gnu.org> References: <87wpkphbj4.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1469296110 1738 80.91.229.3 (23 Jul 2016 17:48:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 23 Jul 2016 17:48:30 +0000 (UTC) Cc: 23814@debbugs.gnu.org To: ynyaaa@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jul 23 19:48:18 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 1bR129-0006h5-H2 for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Jul 2016 19:48:17 +0200 Original-Received: from localhost ([::1]:53166 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bR125-0004yX-JW for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Jul 2016 13:48:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bR11y-0004qP-MG for bug-gnu-emacs@gnu.org; Sat, 23 Jul 2016 13:48:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bR11u-0000tz-Fg for bug-gnu-emacs@gnu.org; Sat, 23 Jul 2016 13:48:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51010) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bR11u-0000tm-Bm for bug-gnu-emacs@gnu.org; Sat, 23 Jul 2016 13:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bR11u-0004wF-6y for bug-gnu-emacs@gnu.org; Sat, 23 Jul 2016 13:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Jul 2016 17:48:02 +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.146929606318954 (code B ref 23814); Sat, 23 Jul 2016 17:48:02 +0000 Original-Received: (at 23814) by debbugs.gnu.org; 23 Jul 2016 17:47:43 +0000 Original-Received: from localhost ([127.0.0.1]:35114 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bR11a-0004ve-Lj for submit@debbugs.gnu.org; Sat, 23 Jul 2016 13:47:42 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:56765) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bR11Z-0004vR-Mk for 23814@debbugs.gnu.org; Sat, 23 Jul 2016 13:47:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bR11T-0000qO-OU for 23814@debbugs.gnu.org; Sat, 23 Jul 2016 13:47:36 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:54938) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bR11P-0000pf-T9; Sat, 23 Jul 2016 13:47:31 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2883 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bR11L-0000NI-SS; Sat, 23 Jul 2016 13:47:30 -0400 In-reply-to: <87wpkphbj4.fsf@gnu.org> (message from handa on Wed, 13 Jul 2016 23:12:47 +0900) 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:121463 Archived-At: Ping! Could you please try this patch and see if it solves the problem? > From: handa > Cc: ynyaaa@gmail.com, 23814@debbugs.gnu.org > Date: Wed, 13 Jul 2016 23:12:47 +0900 > > > > > >> `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 ?~)) > >