help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: url-retrieve and encoding


From: Eli Zaretskii
Subject: Re: url-retrieve and encoding
Date: Sun, 11 Feb 2024 21:21:39 +0200

> Date: Sun, 11 Feb 2024 18:49:25 +0100
> From: tomas@tuxteam.de
> Cc: help-gnu-emacs@gnu.org
> 
> > > Yes: decode-coding-region.
> > 
> > Ahhh -- thanks a bunch for this one! How could I have missed it.
> > 
> > > > (...) But that feels
> > > > a bit... gross:
> > > 
> > > Indeed.  Why didn't you try decoding to begin with?
> 
> OK, now I can answer this question more precisely: actually, I'd
> been there already and was coufused that the function did... nothing.
> 
> Now at least I know why: the buffer is unibyte.

The solution is (quite obviously) not to do that in-place.

Alternatively, you could make the buffer multibyte in advance, but
that's tricky, so I don't recommend that.

> Its content /is/ utf-8.

That's not really 100% accurate, although it's close.  If the unibyte
buffer includes byte sequences that are not valid UTF-8, decoding does
change the byte stream in those places.

> But then... I can do things "in buffer" by simply invoking
> (toggle-enable-multibyte-characters t). At least, it seems to
> work. But... is it a good idea?

No.  Always call the decode function, never play with
multi-uni-byteness, because the latter will eventually surprise (or
bite) you.



reply via email to

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