From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1411C3858D32; Fri, 3 Nov 2023 17:17:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1411C3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1699031868; bh=wHBSN2UUA/+g37wrUEHiAqu04wZ5doSrIYFQv0BJjws=; h=From:To:Subject:Date:From; b=qzqSTr4Uxcey5cC7OQpO0qnMuNnnuV59kTNa1OsFzaVV/CMJQNaSGaau9QfMOpovZ ALCPGmZjadADnQHOs1mWqWmKS5kWvKnYu0azevU0AEUx9cXGyWEJTRkO+rHCRLsYvo fw3WSi5p3xrrkCLwvNa35nNmg01qlXXFjymR0Yfw= From: "bugzilla at tecnocode dot co.uk" To: glibc-bugs@sourceware.org Subject: [Bug locale/31030] New: ERA segments are nul-separated rather than semicolon-separated Date: Fri, 03 Nov 2023 17:17:47 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: locale X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bugzilla at tecnocode dot co.uk X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31030 Bug ID: 31030 Summary: ERA segments are nul-separated rather than semicolon-separated Product: glibc Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: locale Assignee: unassigned at sourceware dot org Reporter: bugzilla at tecnocode dot co.uk Target Milestone: --- nl_langinfo(3) says =E2=80=9CEra description segments are separated by semi= colons=E2=80=9D, but it appears that `nl_langinfo (ERA)` returns them separated by nul bytes instead, and the only way to parse them is to additionally call the (undocumented) `nl_langinfo (_NL_TIME_ERA_NUM_ENTRIES)` to find out how many segments there are meant to be. This can be demonstrated with the following example program (compile with `= gcc -o era era.c -Wall`): ``` #include #include #include #include int main (void) { setlocale (LC_ALL, ""); const char *era =3D nl_langinfo (ERA); int n_entries =3D (int) (intptr_t) nl_langinfo (_NL_TIME_ERA_NUM_ENTRIES); printf ("n_entries: %d, era: %s\n", n_entries, era); return 0; } ``` If run with `LANG=3Dth_TH.UTF-8 ./era` it prints ``` n_entries: 1, era: +:1:-543/01/01:+*:=E0=B8=9E.=E0=B8=A8.:%EC %Ey ``` which is all good. However, if run with `LANG=3Dja_JP.UTF-8 ./era`, it prints: ``` n_entries: 11, era: +:2:2020/01/01:+*:=E4=BB=A4=E5=92=8C:%EC%Ey=E5=B9=B4 ``` There clearly aren=E2=80=99t 11 segments in the =E2=80=99era=E2=80=99 descr= iption there =E2=80=94 only one. Looking at the ja_JP locale definition, there are correctly 11 segments def= ined in it: https://github.com/bminor/glibc/blob/master/localedata/locales/ja_JP#L14949= -L14977 If I read past 10 nul terminators in the `era` string, I can retrieve all 11 segments. So the locale definition does work. It just doesn=E2=80=99t match= up to what nl_langinfo(3) says, and requires using the undocumented `_NL_TIME_ERA_NUM_ENTRIES` to read all segments. Is there a reason `era` is using nul separators? Could it be switched to us= ing semicolons please? :) --=20 You are receiving this mail because: You are on the CC list for the bug.=