emacs-devel
[Top][All Lists]
Advanced

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

Re: [Unicode-2] `read' always returns multibyte symbol


From: Stefan Monnier
Subject: Re: [Unicode-2] `read' always returns multibyte symbol
Date: Wed, 14 Nov 2007 22:39:35 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

> I think it's better, too.  However, there might be a code that
> copies data from nntp-server-buffer to a multibyte buffer.  I'm
> not capable to check all the Gnus code.

I understand the desire to avoid changing code, but I think in the long
run it'll pay off.

>>> (IIUC, copying data from a multibyte buffer to a unibyte buffer
>>> causes no problem).

>> I'm not sure I understand: copying data from a multibyte buffer to
>> a unibyte buffer is exactly the case that can cause problems.

> I agree that's generally true.  But in Gnus' case, data in a
> multibyte work buffer are the multibyte version of binary data.
> I don't know proper words to explain it, sorry.  In other words,
> they are the one which `string-to-multibyte' converted binary
> data to.  For example:

> (with-temp-buffer
>   (set-buffer-multibyte t)
>   (insert (string-to-multibyte (encode-coding-string "日本語" 'utf-8)))
>   (let ((buffer (current-buffer)))
>     (with-temp-buffer
>       (set-buffer-multibyte nil)
>       (insert-buffer-substring buffer)
>       (decode-coding-string (buffer-string) 'utf-8))))
>  => "日本語"

> I'm not sure it works with any data, though.

I'm not sure what you're saying.  But IIUC the source buffer in your
example would be nntp-server-buffer, in which case turning it into
unibyte will not introduce any problem.  On the contrary, it'll make it
more obviously correct.


        Stefan




reply via email to

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