emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [HELP] (bug?) Saving a buffer without any conversion?


From: Kenichi Handa
Subject: Re: [HELP] (bug?) Saving a buffer without any conversion?
Date: Wed, 15 Jan 2003 19:59:04 +0900 (JST)
User-agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.2.92 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI)

In article <address@hidden>, address@hidden (Kim F. Storm) writes:
> He uses a process filter to "insert" the received strings to the
> buffer like this [approximately]:

>         (defun filter (proc string)
>           (with-current-buffer (process-buffer proc)
>             (insert string)))

Ah!  Now I see what's going on.  If the coding system for
proc is no-conversion or raw-text, STRING above is unibyte,
thus, when inserted in a multibyte buffer, it is converted
to the corresponding multibyte string.  This conversion
converts all 0xA0..0xFF to Latin-1 (in Latin-1 lang. env.).

> Here is a small, selfcontained test case.  

> If you eval the following form, wait a few seconds, the result is
>         "BUFFER=10 FILE=20"
> meaning that the temp.out buffer is 10 "bytes", but the written
> file is 20 "bytes".

> Adding the "set-buffer-multibyte" line produces the right result.

Yes.  And, instead of adding that, chaging this:

>             :filter (lambda (proc string)
>                       (with-current-buffer (get-buffer "temp.out")
>                         (insert string)))

to this:

>             :filter (lambda (proc string)
>                       (with-current-buffer (get-buffer "temp.out")
>                         (insert (string-as-multibyte string))))

also produces the right result.

Which is the better solution?  It depends on how the buffer
is used later.  If it is just to save the received bytes in
a file, using a unibyte buffer is better.  But, in that
case, first of all, why is the process filter necessary?


---
Ken'ichi HANDA
address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]