GNU bug report logs -
#53236
26.1; encode-coding-string does not encode the string as expected
Previous Next
Reported by: Markus Triska <triska <at> metalevel.at>
Date: Thu, 13 Jan 2022 19:47:01 UTC
Severity: normal
Found in version 26.1
Done: Markus Triska <triska <at> metalevel.at>
Bug is archived. No further changes may be made.
Full log
Message #14 received at 53236 <at> debbugs.gnu.org (full text, mbox):
On Jan 14 2022, Eli Zaretskii wrote:
>> From: Markus Triska <triska <at> metalevel.at>
>> Date: Thu, 13 Jan 2022 20:45:57 +0100
>>
>> Correspondingly, I expect (encode-coding-string "\200" 'utf-8) to yield
>> a string equivalent to "\xC2\x80", but that seems not to be the case. I get:
>>
>> (encode-coding-string "\200" 'utf-8) --> "\200"
>>
>> And therefore, unexpectedly:
>>
>> (string= (encode-coding-string "\200" 'utf-8) "\xC2\x80") --> nil
>
> "\200" is a unibyte string, and encoding unibyte strings returns those
> strings without changing them.
>
> This is not a bug, just a dark corner of encoding/decoding stuff.
Or a dark corner of the string syntax.
ELISP> (multibyte-string-p "\200")
nil
ELISP> (multibyte-string-p "\x80")
nil
ELISP> (multibyte-string-p "\x0080")
t
ELISP> (encode-coding-string "\x0080" 'utf-8)
"\302\200"
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
This bug report was last modified 3 years and 126 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.