Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #197869

Re: open: 'ascii', 'backslashreplace' not behaving as expected - why?

Path csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From Veek M <veekjunk@foobar.com>
Newsgroups comp.lang.python
Subject Re: open: 'ascii', 'backslashreplace' not behaving as expected - why?
Date Sat, 8 Aug 2026 04:25:43 -0000 (UTC)
Organization A noiseless patient Spider
Lines 16
Message-ID <1156b47$15v7o$2@dont-email.me> (permalink)
References <1155tpv$13on7$1@dont-email.me> <1156074$14bmn$1@dont-email.me> <1156av3$15v7o$1@dont-email.me>
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Injection-Date Sat, 08 Aug 2026 04:25:44 +0000 (UTC)
Injection-Info dont-email.me; logging-data="1244408"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iZYHxb/NRN73GeWThHnvd"; posting-host="d75c4908dd89aa0bd2d1c9efc307aee7"
User-Agent Pan/0.154 (Izium; 517acf4)
Cancel-Lock sha1:qgmdIso7A2r8qvo7PZJ+QIsqZz0= sha256:YgYlcBgGVgS3T+yxYzfvMyWkpgvb3UoxKJ7ogs+kVu4= sha1:5petK1OVYC+aoji1dr8acN+CGwc= sha256:P2JITIZYpNZmrSAJyiCLEfBjaFTaQJmO4FIrGm2bOx8=
Xref csiph.com comp.lang.python:197869

Show key headers only | View raw


On Sat, 8 Aug 2026 04:22:59 -0000 (UTC), Veek M wrote:

> On Sat, 8 Aug 2026 01:19:32 -0000 (UTC), Lawrence D’Oliveiro wrote:
> 
>> b'\xef\xbf\xbf\n'.decode()
> 
> Could you explain how it works and what exactly is going on?
> 
> fh.readline() returns a unicode string with the funny chars (bytes 0xff
> 0xff) encoded as \\xef \\xbf \\xbf - why is it \\? why not just use a
> single u'\xef\xbf\xbf' - why is he escaping the '\'.
> 
> Also - how exactly is he getting ef bf bf and not ff ff?

oh is 0xff 0xff when encoded to disk in utf-8 
(sys.getsystemdefaultencoding) 0xef 0xbf 0xbf?

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

open: 'ascii', 'backslashreplace' not behaving as expected - why? Veek M <veekjunk@foobar.com> - 2026-08-08 00:38 +0000
  Re: open: 'ascii', 'backslashreplace' not behaving as expected - why? Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-08 01:19 +0000
    Re: open: 'ascii', 'backslashreplace' not behaving as expected - why? Veek M <veekjunk@foobar.com> - 2026-08-08 04:22 +0000
      Re: open: 'ascii', 'backslashreplace' not behaving as expected - why? Veek M <veekjunk@foobar.com> - 2026-08-08 04:25 +0000
        Re: open: 'ascii', 'backslashreplace' not behaving as expected - why? Veek M <veekjunk@foobar.com> - 2026-08-08 04:33 +0000
          Re: open: 'ascii', 'backslashreplace' not behaving as expected - why? Greg Ewing <greg.ewing@canterbury.ac.nz> - 2026-08-10 12:08 +1200

csiph-web