From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 62B5D3894E63; Mon, 11 May 2020 20:59:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62B5D3894E63 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589230782; bh=L7+x1HT3fbASuq3h3mI53Rs9JPzBM3sUy5oXjTmXpgo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rGslZLRNYWTt4RSBTp6TfV52ikZH+klvp8FL1l7shmEM0PvlIQUwOJ0Sjuo/ChFgj 7erR9P1bXOl9hIKZXEaS7nA4PZYTIZRlW3EEQjL+rNfoblBgA62u0phfD2IM97z8+G 89uKeNbad3mZTx16s0F4s79UdwAXVbHwkGN7s6eM= From: "carlos at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/95048] wstring-constructor of std::filesystem::path throws for non-ASCII characters Date: Mon, 11 May 2020 20:59:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: carlos at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 May 2020 20:59:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95048 Carlos O'Donell changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |carlos at redhat dot com --- Comment #2 from Carlos O'Donell --- (In reply to Jonathan Wakely from comment #1) > This happens because glibc won't convert the wide string to UTF-8: >=20 > #include > #include >=20 > int main() > { > const wchar_t wstr[] =3D L"=C3=A4"; > const wchar_t* from =3D wstr; > char to[10]; > mbstate_t s; > size_t res =3D wcsnrtombs(to, &from, 1, sizeof(to), &s); > assert(res !=3D (size_t)-1); > } >=20 > I'm not yet sure why glibc refuses to convert that. ISO C says: "At program startup, the equivalent of setlocale(LC_ALL, "C"); is executed." Which means you are trying to convert UTF-8 to ASCII. You should call setlocale with a non-ASCII character set to make this work.=