[Top][All Lists]

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

Re: unibyte<->multibyte conversion [Re: Emacs-diffs Digest, Vol 2, Issue

From: Stefan Monnier
Subject: Re: unibyte<->multibyte conversion [Re: Emacs-diffs Digest, Vol 2, Issue 28]
Date: Mon, 20 Jan 2003 19:54:28 -0500

> > While we're at it, how about making string-as-multibyte obsolete ?
> > It's not used much and it has been abused many times in the past.
> It is useful for instance in this scenario.  I don't
> remember a concrete example, but some package is doing this
> kind of thing.
> Read a file of weird encoding in a unibyte buffer.  Parse
> the contents and do decode-coding-region one bunch by one
> with different coding systems.  Extract some part from that
> unibyte buffer and insert it in a mulitbyte buffer.   The
> last step is:
>    (let ((str (buffer-substring FROM TO)))
>      (save-excursion
>        (set-buffer MULTIBYTE-BUF)
>        (insert (string-as-multibyte str))))

Without a concrete example I don't find this scenario compelling.
E.g. I fail to see why it should do

 decode-coding-region + buffer-substring + string-as-multibyte

rather than

 buffer-substring + decode-coding-string

But even if the scenario is possible,
using (decode-coding-region str 'emacs-mule) doesn't seem much worse
than (string-as-multibyte str), so I'm not sure how relevant it is
to whether or not we should obsolete string-as-multibyte.

> > Also, I believe it's more or less equivalent to
> >   (decode-coding-string str 'emacs-mule)
> Yes, for the moment.   But, in emacs-unicode, we must change
> it to:
>       (decode-coding-string str 'utf-8-emacs)
> On the other hand, we don't have to change a code using
> string-as-multibyte.

So I hereby suggest (define-coding-system-alias 'internal 'emacs-mule)
which we can happily change in Emacs-22 to `utf-8-emacs', such that
we will still have

 (string-as-multibyte str) == (decode-coding-string str 'internal)

-- Stefan

reply via email to

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