[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#23814: 24.5; bug of hz coding-system
From: |
ynyaaa |
Subject: |
bug#23814: 24.5; bug of hz coding-system |
Date: |
Sun, 24 Jul 2016 17:21:08 +0900 |
Eli Zaretskii <eliz@gnu.org> writes:
> Ping! Could you please try this patch and see if it solves the
> problem?
The patch seems to make better results.
But I found other bugs about decodings of "~" escape.
"~~" and "~{!!~}" should be encoded and decoded as below.
"~~" -> "~~~~" -> "~~"
"~{!!~}" -> "~~{!!~~}" -> "~{!!~}"
In really they are encoded properly, but decoded in wrong way.
(decode-coding-string (encode-coding-string "~~" 'hz) 'hz)
=> "~"
(decode-coding-string (encode-coding-string "~{!!~}" 'hz) 'hz)
=> #("\x3000" 0 1 (charset chinese-gb2312))
These behaviors are not affected by the patch.
>> 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 ?~))
>>
>>