From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: docs for insert-file-contents use 'bytes' Date: Mon, 29 Sep 2008 16:04:13 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <86hc7y64vm.fsf@lifelogs.com> References: <86ljxa67xi.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1222722532 11235 80.91.229.12 (29 Sep 2008 21:08:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 29 Sep 2008 21:08:52 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 29 23:09:51 2008 connect(): Connection refused 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 1KkPwr-00085Q-7D for ged-emacs-devel@m.gmane.org; Mon, 29 Sep 2008 23:06:29 +0200 Original-Received: from localhost ([127.0.0.1]:36013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KkPvo-00019K-Dk for ged-emacs-devel@m.gmane.org; Mon, 29 Sep 2008 17:05:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KkPvk-000195-4L for emacs-devel@gnu.org; Mon, 29 Sep 2008 17:05:20 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KkPvj-00018e-LV for emacs-devel@gnu.org; Mon, 29 Sep 2008 17:05:19 -0400 Original-Received: from [199.232.76.173] (port=39691 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KkPvj-00018b-6b for emacs-devel@gnu.org; Mon, 29 Sep 2008 17:05:19 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:48032 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KkPvi-00052k-5n for emacs-devel@gnu.org; Mon, 29 Sep 2008 17:05:18 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1KkPvY-0001fT-WF for emacs-devel@gnu.org; Mon, 29 Sep 2008 21:05:09 +0000 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 29 Sep 2008 21:05:08 +0000 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 29 Sep 2008 21:05:08 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 39 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:GtpU0LCvUV5zMgbDQGXVHidJFRI= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:104235 Archived-At: On Mon, 29 Sep 2008 23:12:58 +0300 Eli Zaretskii wrote: >> From: Ted Zlatanov >> Date: Mon, 29 Sep 2008 14:58:17 -0500 >> >> The docs for insert-file-contents say the range is in bytes, but that >> function does decoding of the contents. Can it, therefore, read from an >> undesirable position (e.g. the middle of a UTF-8 sequence)? EZ> The range _is_ in bytes (you will see in fileio.c that Emacs uses EZ> `lseek' to get to the required file positions). Yes, reading a part EZ> of a multibyte sequence is a possibility. >> How does Emacs handle that? EZ> Like with any other random bytes, I think: it will produce eight-bit-* EZ> characters in the buffer. IOW, you get garbled text. This is not a safe operation mode with multibyte sequences; is there a way to DTRT? I'm specifically thinking about a paged buffer mode where you only see a small portion of the file (for editing large files, as we discussed in another newsgroup a while ago). >> Either way the docs need to state the operation mode clearly. EZ> Assuming I don't miss anything, and the above is indeed correct, what EZ> would you like the doc string to say, exactly? Maybe add: "Warning: this is not safe with variable-length multibyte encodings such as UTF-8, because it works by byte offset without encoding awareness, so you may get garbled data. See ??? instead." I don't know if this is the right wording, but it's a pretty essential operation so it should give some warning about this common (nowadays) case. Ted