[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `write-region' writes different bytes than passed to it?
From: |
Eli Zaretskii |
Subject: |
Re: `write-region' writes different bytes than passed to it? |
Date: |
Tue, 11 Dec 2018 17:41:12 +0200 |
> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Tue, 11 Dec 2018 13:30:07 +0100
>
> 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?
Yes, because "\xC1\xB2" just happens to be the internal multibyte
representation of a raw-byte F2. Raw bytes are always converted to
their single-byte values on output, regardless of the encoding you
request.