From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: Re: Need some help with Rmail/mbox Date: Mon, 22 Sep 2008 13:31:56 +0900 Message-ID: References: <87y71o4xw6.fsf@xemacs.org> <48D33A10.4040102@pajato.com> <871vzfi93y.fsf@xemacs.org> <03b276ff-e070-465e-9486-c02e4725a3e0@broken.deisui.org> <1bd9e4e5-9349-438b-92af-c2a6293491e7@broken.deisui.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1222057948 1853 80.91.229.12 (22 Sep 2008 04:32:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 22 Sep 2008 04:32:28 +0000 (UTC) Cc: pmr@pajato.com, eliz@gnu.org, ueno@unixuser.org, stephen@xemacs.org, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 22 06:33:20 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Khd6t-0007ac-C3 for ged-emacs-devel@m.gmane.org; Mon, 22 Sep 2008 06:33:19 +0200 Original-Received: from localhost ([127.0.0.1]:41209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Khd5r-0003dB-9X for ged-emacs-devel@m.gmane.org; Mon, 22 Sep 2008 00:32:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Khd5m-0003d0-Cm for emacs-devel@gnu.org; Mon, 22 Sep 2008 00:32:10 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Khd5l-0003co-Ms for emacs-devel@gnu.org; Mon, 22 Sep 2008 00:32:10 -0400 Original-Received: from [199.232.76.173] (port=49231 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Khd5l-0003cl-GH for emacs-devel@gnu.org; Mon, 22 Sep 2008 00:32:09 -0400 Original-Received: from mx1.aist.go.jp ([150.29.246.133]:37880) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Khd5f-0002EH-9A; Mon, 22 Sep 2008 00:32:03 -0400 Original-Received: from rqsmtp1.aist.go.jp (rqsmtp1.aist.go.jp [150.29.254.115]) by mx1.aist.go.jp with ESMTP id m8M4VvwE004304; Mon, 22 Sep 2008 13:31:57 +0900 (JST) env-from (handa@m17n.org) Original-Received: from smtp1.aist.go.jp by rqsmtp1.aist.go.jp with ESMTP id m8M4Vv66021601; Mon, 22 Sep 2008 13:31:57 +0900 (JST) env-from (handa@m17n.org) Original-Received: by smtp1.aist.go.jp with ESMTP id m8M4Vuoq025819; Mon, 22 Sep 2008 13:31:56 +0900 (JST) env-from (handa@m17n.org) Original-Received: from handa by etlken.m17n.org with local (Exim 4.69) (envelope-from ) id 1Khd5Y-00042x-Hc; Mon, 22 Sep 2008 13:31:56 +0900 In-reply-to: (message from Stefan Monnier on Sun, 21 Sep 2008 18:07:10 -0400) User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/23.0.60 (i686-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) X-detected-operating-system: by monty-python.gnu.org: Solaris 9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:104025 Archived-At: In pre-unicode-merge Emacs (more exactly, before 2008-03-12), the automatic unibyte -> multibyte conversion sometimes caused a headache for Emacs Lisp developper because the behaviour differs in each lang. env. But, with the current Emacs, that conversion works more developper-friendly; i.e. all bytes with MSB set are converted to the corresponding eight-bit characters of multibyte represenation (* see the attached note). So, now we have these four ways to get a multibute buffer decoded from a unibyte buffer, and they all should work equally safely. (1) Do decode-coding-region while specifying a multibyte buffer as TARGET. (2) Insert the contents of unibyte buffer into a multibyte buffer, and then perform decode-coding-region in that multibyte buffer. (3) Get a unibyte string form a unibyte buffer, and then decode it while specifying a multibyte buffer as TARGET. (4) Deocde a unibyte buffer into a mulitbyte string, and then insert it into a multibyte buffer. (Please note that using decode-coding-region directly in a unibyte-buffer is not reliable because if a coding system has post-read-converion function, that funcion (usually) works only in a mutlibyte buffer.) The efficiency is (1) > (2) > (3) > (4). And, for the case of Rmail/mbox, before decoding, we may have to perform base64 or qp decoding, and they can't specify the different buffer/string as target. And I don't know if they works for a multibyte buffer/string. So, at the moment, I think the following strategy is good. Copy the contents of RMAIL buffer to a temporary unibyte buffer, perform base64/qp decoding in that buffer, then do decode-coding-region while specifying the view buffer as TARGET. --- Kenichi Handa handa@ni.aist.go.jp * Note: Those eight-bit characters have values #x3FFF80..#x3FFFFF, and, for instance, char-after and aref return one of those values. To get the original byte value, one needs (encode-char EIGHT-BIT-CHAR 'eight-bit) or (multibyte-char-to-unibyte EIGHT-BIT-CHAR). Perhaps, we have to provide some APIs for directly getting a byte value of EIGHT-BIT-CHAR, but we have not yet decided what to do.