Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Yo baby yo baby yo." -- Eddie Murphy


devel / comp.lang.python / Re: tail

SubjectAuthor
o Re: tailMRAB

1
Re: tail

<mailman.339.1651942875.20749.python-list@python.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=18175&group=comp.lang.python#18175

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: pyt...@mrabarnett.plus.com (MRAB)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Sat, 7 May 2022 17:58:05 +0100
Lines: 30
Message-ID: <mailman.339.1651942875.20749.python-list@python.org>
References: <CABbU2U-_Z546umxtnZXL8b1LUERCnyOxYw6osKTvKncOHFkJ3A@mail.gmail.com>
<60454E09-0ADA-4881-A84B-6C11397D244F@barrys-emacs.org>
<CABbU2U99Jpa6nuYg0sXw6=GjBEKVk9u-_oyxSoL8hLrW_2FoBA@mail.gmail.com>
<561ac7a8-2034-c1ce-6fca-f4280baac409@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de Kh1pNlTpKgCDPZfE1uCcTwrvUig2VjhQBJIcZeCwmukQ==
Return-Path: <python@mrabarnett.plus.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=plus.com header.i=@plus.com header.b=ivE/ylOY;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.013
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; '2022': 0.05; 'bin': 0.09;
'from:addr:python': 0.09; 'received:192.168.1.64': 0.09; '>>>>':
0.16; 'barry': 0.16; 'encoding': 0.16;
'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16;
'message-id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16;
'received:84.93.230': 0.16; 'received:plus.net': 0.16; 'specify':
0.16; 'unit,': 0.16; 'wrote:': 0.16; 'to:addr:python-list': 0.20;
'sat,': 0.22; 'code': 0.23; '>>>': 0.28; 'header:User-Agent:1':
0.30; 'received:192.168.1': 0.32; 'but': 0.32; "didn't": 0.34;
'skip:" 20': 0.34; 'header:In-Reply-To:1': 0.34; 'handling': 0.35;
'cases': 0.36; 'those': 0.36; "it's": 0.37; 'hard': 0.37;
'received:192.168': 0.37; 'file': 0.38; 'could': 0.38; 'added':
0.39; 'handle': 0.39; 'use': 0.39; 'want': 0.40; 'mode': 0.62;
'skip:b 20': 0.63; 'skip:b 10': 0.63; 'per': 0.68; 'skip:" 40':
0.84; 'sulla': 0.84; 'trick': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
t=1651942688; bh=42/DtsYu95ML/2ZRIoQVVoppkz+ZuFb0dQibIQbAzBg=;
h=Date:Subject:To:References:From:In-Reply-To;
b=ivE/ylOYb97xSrJ2IZ2OEwI+jdtxajXzYhwhi1umGDUUzvQZNB0Ssp1RpM+1T9wwS
8wwBmdGV4K9uj2CTFcqNZgvJeIvrSYXUutW9qgGzu11ZqE/3JqMSBt9h0ZT8hpXvKy
kXyBE33PG26za9YwrmktFh3ulCFoLr3q3vB324tSsuoGvFdPsDMqCJrniqCkYNAS27
wgA7s3NEZi5eBGbIGzzOcyA1SNGZ8SoOD6yTiAfo6BakUitd17bISF6h4SVsSPVjEn
esT7OkFqb28yvpAKTKdy25dzzLePFETPjzRMuVWoBkQdtLWuKxm0ojrytMwqqIg2Xm
4v91g95pFUvow==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.4 cv=JPUoDuGb c=1 sm=1 tr=0 ts=6276a520
a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
a=IkcTkHD0fZMA:10 a=pJ0dDMpWAAAA:8 a=0yrDsjHOZDiCbtq5M08A:9 a=QEXdDO2ut3YA:10
a=7HhFaE7EYeXGtY87cTDK:22
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Content-Language: en-GB
In-Reply-To: <CABbU2U99Jpa6nuYg0sXw6=GjBEKVk9u-_oyxSoL8hLrW_2FoBA@mail.gmail.com>
X-CMAE-Envelope: MS4xfCFT6e2rCeBVCq8HAZ3yiARfEKyeCrGSuF+sFuc70oucBNaggCkLlucedZSBsM7M4rRfMLIlyL6uWU6wwoR7YKujt2u47FAF1jjFstkZasLbN+xwVtNd
yoOYGyPUNWg5keIM3HZ33xIRkhk507jRRQxl2ZkkS+AVCFzyAUyqBF4GtAswNCXL1icBmDOcG4WhZhqVEjzh/fVbIGZXnNNIvfI=
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <561ac7a8-2034-c1ce-6fca-f4280baac409@mrabarnett.plus.com>
X-Mailman-Original-References: <CABbU2U-_Z546umxtnZXL8b1LUERCnyOxYw6osKTvKncOHFkJ3A@mail.gmail.com>
<60454E09-0ADA-4881-A84B-6C11397D244F@barrys-emacs.org>
<CABbU2U99Jpa6nuYg0sXw6=GjBEKVk9u-_oyxSoL8hLrW_2FoBA@mail.gmail.com>
 by: MRAB - Sat, 7 May 2022 16:58 UTC

On 2022-05-07 17:28, Marco Sulla wrote:
> On Sat, 7 May 2022 at 16:08, Barry <barry@barrys-emacs.org> wrote:
>> You need to handle the file in bin mode and do the handling of line endings and encodings yourself. It’s not that hard for the cases you wanted.
>
>>>> "\n".encode("utf-16")
> b'\xff\xfe\n\x00'
>>>> "".encode("utf-16")
> b'\xff\xfe'
>>>> "a\nb".encode("utf-16")
> b'\xff\xfea\x00\n\x00b\x00'
>>>> "\n".encode("utf-16").lstrip("".encode("utf-16"))
> b'\n\x00'
>
> Can I use the last trick to get the encoding of a LF or a CR in any encoding?

In the case of UTF-16, it's 2 bytes per code unit, but those 2 bytes
could be little-endian or big-endian.

As you didn't specify which you wanted, it defaulted to little-endian
and added a BOM (U+FEFF).

If you specify which endianness you want with "utf-16le" or "utf-16be",
it won't add the BOM:

>>> # Little-endian.
>>> "\n".encode("utf-16le")
b'\n\x00'
>>> # Big-endian.
>>> "\n".encode("utf-16be")
b'\x00\n'

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor