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: Mario Lang
Subject: Re: [HELP] (bug?) Saving a buffer without any conversion?
Date: Wed, 15 Jan 2003 17:59:10 +0100
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-pc-linux-gnu)

Kenichi Handa <address@hidden> writes:

> 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.).

Thanks for this explaination.  As Kim already pointed out, I think this
should be documented somewhere more clearly.  At least to me it was very
mysterious why some kind of conversion happend, even if I specified
'no-conversion in all possible places...

>> 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?

In that specific case, the filter function is necessary because the protocol
used requires sending confirmation-packets whenever we received data...

-- 
Thanks again,
  Mario




reply via email to

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