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 5C5BA385828F for ; Mon, 25 Mar 2024 11:34:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C5BA385828F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5C5BA385828F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711366456; cv=none; b=T0O7IIvwxjd3O/CqOYd9n2WLxbEtGI/kX6BIc0r10G3hC7m+hwVDtPLsSzPanlxlKRmnCOD2QyS6SOMFXukmDPCPaxRLUlkCHhCZtdxA5BFyuwFVnwPj0jzkr0h5Fe7TMi62KlXAfBTqB8gL9XX7aYYWotWOoYsB42Fg48mPJY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711366456; c=relaxed/simple; bh=QG00+a/EoD/Fo9FOd8sbGuupBPxsKX/sPnxlpYsZYhk=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=UaScHfcKYPAyYsjM9NgVAe/ECxwu/1OFRw+IwCE5nuw/hj8DNpJEn2mvBLJ97LHD2bvX32FqodqVA560njGlrxqgLLvqzb/uYtIAtj3cNPTy8v83wt6uocrVztt0AvVGEi4SeCIob+enH3kWH+ciUm+37zdmV5wxnqJmkzZ3Aug= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711366455; h=from:from:reply-to: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=hz9LBe4jLaRWN9BbQ/ETNotmDy9BBlvmxWgk4wTaEDU=; b=RJ0Tkng6hk02fk8Fh5r9T5bJFO9oC9rxI7z2Phj7BBdXXwbKRhnK69mG1lv9apgLUYbfCQ CfV5R8RmSo4T5WbjvFAHuZbyXmI9UojJZlow7uSlzuEidKHvnTbUKv2IP3j0yquhAZcSeG 1IF9nfFXbkGXTHQbV9wMyjMmE3udKHU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-612-DcuvUh2TMj2Tlapizn1QbQ-1; Mon, 25 Mar 2024 07:34:13 -0400 X-MC-Unique: DcuvUh2TMj2Tlapizn1QbQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3CCB7800264; Mon, 25 Mar 2024 11:34:13 +0000 (UTC) Received: from calimero.vinschen.de (unknown [10.39.192.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A6CC1C060A4; Mon, 25 Mar 2024 11:34:12 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id A009FA80B9E; Mon, 25 Mar 2024 12:34:07 +0100 (CET) Date: Mon, 25 Mar 2024 12:34:07 +0100 From: Corinna Vinschen To: Bruno Haible Cc: Jun T , newlib@sourceware.org Subject: Re: wctomb() accepts out-of-range character in C-locale Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: Bruno Haible , Jun T , newlib@sourceware.org References: <7028441.Tto2BC3hUo@nimes> MIME-Version: 1.0 In-Reply-To: <7028441.Tto2BC3hUo@nimes> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.8 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_H4,RCVD_IN_MSPIKE_WL,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: Hi Bruno, On Mar 25 12:26, Bruno Haible wrote: > Hi Corinna, > > > Jun T wrote: > > > --------------------------------------- > > > #include > > > #include > > > #include > > > > > > int main() { > > > char buf[MB_CUR_MAX]; > > > setlocale(LC_ALL, "C"); > > > printf("%d\n", wctomb(buf, 0x80)); > > > return 0; > > > } > > > --------------------------------------- > > > > > > On Linux it outputs '-1'. > > "On Linux" is ambiguous: > - In glibc, it outputs -1 because of this glibc bug: > https://sourceware.org/bugzilla/show_bug.cgi?id=19932 > https://sourceware.org/bugzilla/show_bug.cgi?id=29511 > - In musl libc, it outputs -1 because the "C" locale (like all locales) > uses UTF-8 encoding and the lone byte "\x80" is not an entire character > in UTF-8. > > > > But a wide character >= 0x80 can't be converted into a valid > > > character in C-loccale (7bit), I think. > > Err. "C" locale, a.k.a. "POSIX" locale, is not 7-bit but 8-bit. > Quoting https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/basedefs/V1_chap06.html#tag_06_02 : > "The POSIX locale shall contain 256 single-byte characters ..." Yeah, now that you mention it... I should have thought of this myself :} > > During testing I found that gnulib was replacing various functions built > > into Cygwin for several reasons, and one of them was that the conversion > > of wide char to multibyte in the "C" locale was not transparently > > converting chars from 0x80 up to 0xff. > > What you did is to make Cygwin POSIX compliant in this aspect, which is > good. > > > I'm actually puzzled right now that this doesn't work in GLibc either. > > It's the aforementioned glibc bug. > > > Do you have an idea what gnulib configure test might have been the > > trigger for the above revert? > > It's the "checking whether the C locale is free of encoding errors..." test > (macro gl_MBRTOWC_C_LOCALE in m4/mbrtowc.m4). > > Bruno Great, so we're in the clear here. Thanks a lot for your (as usual 👍) informative input! Corinna