[Top][All Lists]

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

Re: `write-region' writes different bytes than passed to it?

From: Philipp Stephani
Subject: Re: `write-region' writes different bytes than passed to it?
Date: Tue, 11 Dec 2018 13:42:59 +0100

Am Di., 11. Dez. 2018 um 13:30 Uhr schrieb Philipp Stephani
> Hi,
> usually `write-region' uses the coding system bound to
> `coding-system-for-write'. However, I've found a case where this
> doesn't seem to be the case:
> $ emacs -Q -batch -eval '(let ((coding-system-for-write (quote
> utf-8-unix))) (write-region "\xC1\xB2" nil "/tmp/test.txt"))' && hd
> /tmp/test.txt
> 00000000  f2                                                |.|
> 00000001
> That is, instead of the byte sequence C1 B2 it writes the single byte
> F2, which is an invalid UTF-8 sequence. Is that expected?

I've realized that I can use either string-to-multibyte or
string-as-multibyte to force writing the expected bytes. Still it
seems weird that when confronted with an invalid UTF-8 sequence
`write-region' occasionally writes a *different* invalid UTF-8

reply via email to

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