From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id C472D3858D1E for ; Thu, 10 Nov 2022 08:11:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C472D3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668067861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q4aZKLm0G5XzhRF6hEPK4rHTMMW/ZnuyR7XY5CSSQ8Y=; b=gj0BHHQKqYqmnlLZ+cLCGrqW3vfxkhzJjMa+kKz/sre7Hmv0ba1hQdDRJOMG6lKUZVb5ak n2uT0B7rKiYq+ssB/1nQK4PekT6Ly1JbbNbqmi+CHjs6wHVihcjOTTofdMOs1UG6eM+8hQ P9VWUdaROhYNipxyIjQZBoyp04aUUcU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-316-OGLe1MN6MdCGbpWaZGx7_g-1; Thu, 10 Nov 2022 03:11:00 -0500 X-MC-Unique: OGLe1MN6MdCGbpWaZGx7_g-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 02E16862FDF; Thu, 10 Nov 2022 08:11:00 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.193.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0554E2024CC6; Thu, 10 Nov 2022 08:10:58 +0000 (UTC) From: Florian Weimer To: =?utf-8?B?0L3QsNCx?= Cc: libc-alpha@sourceware.org, Victor Stinner Subject: Re: [PATCH v6 2/2] POSIX locale covers every byte [BZ# 29511] References: <969aa82c8d5904c1d2040bba87abe2f17a0dc647.1667409408.git.nabijaczleweli@nabijaczleweli.xyz> <874jv8dxat.fsf@oldenburg.str.redhat.com> Date: Thu, 10 Nov 2022 09:10:57 +0100 In-Reply-To: <874jv8dxat.fsf@oldenburg.str.redhat.com> (Florian Weimer's message of "Wed, 09 Nov 2022 15:20:26 +0100") Message-ID: <87wn8344by.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * Florian Weimer: > * =D0=BD=D0=B0=D0=B1: > >> This is a logistically trivial patch, >> largely duplicating the extant ASCII code with the error path changed > > I wouldn't say it's trivial in the commit message. 8-) > >> There are two user-facing changes: >> * nl_langinfo(CODESET) is "POSIX" instead of "ANSI_X3.4-1968" >> * mbrtowc() and friends return b if b <=3D 0x7F else +b >> >> Since Issue 7 TC 2/Issue 8, the C/POSIX locale, effectively, >> (a) is 1-byte, stateless, and contains 256 characters >> (b) they collate in byte order >> (c) the first 128 characters are equivalent to ASCII (like previous) >> cf. https://www.austingroupbugs.net/view.php?id=3D663 for a summary of >> changes to the standard; >> in short, this means that mbrtowc() must never fail and must return >> b if b <=3D 0x7F else ab+c for all bytes b >> where c is some constant >=3D0x80 >> and a is a positive integer constant >> >> By strategically picking c=3D we land at the tail-end of the >> Unicode Low Surrogate Area at DC00-DFFF, described as >> > Isolated surrogate code points have no interpretation; >> > consequently, no character code charts or names lists >> > are provided for this range. >> and match musl > > Sadly this doesn't match Python and PEP 540: > >>>> b'\x80'.decode('UTF-8', errors=3D'surrogateescape') > '\udc80' > > I believe the implementation translates this to 0xDF80 instead. > > Not sure what is more important here, musl compatibility or Python > compatibility. Cc:ing Victor in case he as comments. I should probably > ask on the musl list as well as how this divergence came to pass. Raised on the musl list here: Choice of wchar_t mapping for non-ASCII bytes in the POSIX locale > This change definitely needs a NEWS entry. (With this I meant the change overall, not the encoding.) Thanks, Florian