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?

From Veek M <veekjunk@foobar.com>
Newsgroups comp.lang.python
Subject Re: open: 'ascii', 'backslashreplace' not behaving as expected - why?
Date 2026-08-08 04:25 +0000
Organization A noiseless patient Spider
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>

Show all headers | 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