Re: encoding question

2023-07-21 Thread наб via austin-group-l at The Open Group
On Fri, Jul 21, 2023 at 01:38:18AM +, Thorsten Glaser wrote:
> Eric Blake dixit:
> >https://sourceware.org/pipermail/libc-alpha/2023-July/149588.html
> Which has:
> >There are two user-facing changes:
> >  * nl_langinfo(CODESET) is "POSIX" instead of "ANSI_X3.4-1968"
> DON’T do that. For two reasons:
> ① "POSIX" is not a codeset. It’s entirely possible, TTBOMK, to
>   have a conforming system that uses EBCDIC (it’s just not
>   possible to support both EBCDIC‑ and ASCII-based at the same
>   time).
Hm, you may be right here. The wording clearly favours ASCII
(including defining the collation sequence to be ASCII-in-order in
 XBD 7.3.2.6, and having explicit requirements for ASCII-mapped
 POSIX locales)
but there's nothing stopping you from making it actually be in any
random order, so long as you map all ASCII characters and collate them
like ASCII (XBD 6.1, lineno Issue 8 Draft 3):
  3826  6.2 Character Encoding
  3827  The POSIX locale shall contain 256 single-byte characters including the 
characters in Table 6-1
  3828  (on page 117) and Table 6-2 (on page 122), which have the properties 
listed in Section 7.3.1 (on
  3829  page 131). It is unspecified whether characters not listed in those two 
tables are classified as
  3830  punct or cntrl, or neither. Other locales shall contain the characters 
in Table 6-1 (on page 117)
  3831  and may contain any or all of the control characters identified in 
Table 6-2 (on page 122); the
  3832  presence, meaning, and representation of any additional characters are 
locale-specific.

Table 6-1 is the Portable Character Set with U, U0007-U000D, and
U0020-U007E and Table 6-2 is the Non-Portable Control Characters with
U0001-U0006, U000E-U001F, and U007F.

> ② Applications are checking for codesets, and "ANSI_X3.4-1968"
>   is in lists of known ones. This is therefore ABI.
That's not getting killed in my patchset, FTR. It's just no longer
the codeset for the POSIX/C/default locale.

> Since ASCII only specifies the lower 128 characters, and these
> don’t change, I think it’s still appropriate to keep using that
> codeset name.
I decided to keep the 128-byte+error encoding precisely so existing
iconv users don't observe a behaviour change (since, as you said,
it's ABI).

That said: yes, sure. All other systems call the codeset for their
POSIX/C/default locale "ASCII"/"646"/"US-ASCII" anyway (see msgid
),
so keeping the seemingly-ASCII-only name for the POSIX codeset is
established practice. I can do that for v18. But it'd change the
heretofore-stable "ANSI_X3.4-1968" codeset (and it would no longer
be actually, well, /be/ ANSI_X3.4-1968), so I expected that to be
controversialer.

Best,


signature.asc
Description: PGP signature


Re: encoding question

2023-07-20 Thread Thorsten Glaser via austin-group-l at The Open Group
Eric Blake dixit:

>https://sourceware.org/pipermail/libc-alpha/2023-July/149588.html

Which has:

>There are two user-facing changes:
>  * nl_langinfo(CODESET) is "POSIX" instead of "ANSI_X3.4-1968"

DON’T do that. For two reasons:

① "POSIX" is not a codeset. It’s entirely possible, TTBOMK, to
  have a conforming system that uses EBCDIC (it’s just not
  possible to support both EBCDIC‑ and ASCII-based at the same
  time).

② Applications are checking for codesets, and "ANSI_X3.4-1968"
  is in lists of known ones. This is therefore ABI.

Since ASCII only specifies the lower 128 characters, and these
don’t change, I think it’s still appropriate to keep using that
codeset name.

bye,
//mirabilos
-- 
22:20⎜ The crazy that persists in his craziness becomes a master
22:21⎜ And the distance between the craziness and geniality is
only measured by the success 18:35⎜ "Psychotics are consistently
inconsistent. The essence of sanity is to be inconsistently inconsistent



Re: encoding question

2023-07-20 Thread Thorsten Glaser via austin-group-l at The Open Group
Eric Blake dixit:

>The conclusion in those links appears to be that it is compliant to
>have the 8-bit characters map to wchar_t codepoints that are not valid

Thanks.

>encoding errors.  Whether the mapping is to the 0xdcXX or 0xdfXX range
>of reserved codepoints in Unicode is a matter of implementation
>choice; both choices exist in implementations already out there.

Three, actually. I used U+EF80‥U+EFFF for raw octets before the
py3k use of surrogates was even a thing, and even registered that
range with the CSUR. But I’m moving to 21-bit Unicode, from 16-bit,
and want out of the PUA and will not be choosing a range inside the
surrogates either so encountering surrogates in wchar_t won’t get
accidents ☺

I’ve somewhat definitely decided on U-001BBB80‥U-001BBBFF. This
is outside the range of codepoints yet within the 21-bit space
and visually easier to distinguish; keeping bit7 high has a side
benefit.

I’m already using these for my “UTF-8 but pass through raw octets”
scheme but was considering using identical wide character values
for high-bit7 single-byte “multibyte” characters in the "C" locale.

Thanks,
//mirabilos
-- 
„Cool, /usr/share/doc/mksh/examples/uhr.gz ist ja ein Grund,
mksh auf jedem System zu installieren.“
-- XTaran auf der OpenRheinRuhr, ganz begeistert
(EN: “[…]uhr.gz is a reason to install mksh on every system.”)



Re: encoding question

2023-07-18 Thread Eric Blake via austin-group-l at The Open Group
On Sat, Jul 15, 2023 at 10:41:49PM +, Thorsten Glaser via austin-group-l at 
The Open Group wrote:
> Hi,
> 
> I get that the POSIX locale must be a single-byte character locale
> where all 256 octets are characters. I’ve got a question about the
> wide character representation.
> 
> Assuming my POSIX locale uses ASCII as encoding, I’ve got the whole
> portable character set (and then some) in the first 128 codepoints,
> which have the ASCII code as both octet SBCS value and wchar_t value.
> In this scenario, is it permissible to map the other 128 codepoints
> “high” i.e. to wchar_t values > 0x0100?

You're not the first to ask this question.  Here's a link to a
proposed patch to glibc on the same topic just this month, after
noting that musl has already dealt with it:

https://sourceware.org/pipermail/libc-alpha/2023-July/149588.html
https://sourceware.org/pipermail/libc-alpha/2023-July/150021.html
https://www.openwall.com/lists/musl/2022/11/10/2

The conclusion in those links appears to be that it is compliant to
have the 8-bit characters map to wchar_t codepoints that are not valid
Unicode characters, but which are distinct enough to preserve all
other properties needed to treat the POSIX locale as a single-byte
locale with 256 "characters" and proper collation sequence without
encoding errors.  Whether the mapping is to the 0xdcXX or 0xdfXX range
of reserved codepoints in Unicode is a matter of implementation
choice; both choices exist in implementations already out there.

> 
> I’m reading the standard as yes, but not asking already landed me
> in trouble in the past so I’d rather…

That's a wise course of action.  And while maybe the standard could
make this easier, the fact that there are already two commonly chosen
ranges already in play is not going to make it easy to mandate a
specific mapping.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



encoding question

2023-07-15 Thread Thorsten Glaser via austin-group-l at The Open Group
Hi,

I get that the POSIX locale must be a single-byte character locale
where all 256 octets are characters. I’ve got a question about the
wide character representation.

Assuming my POSIX locale uses ASCII as encoding, I’ve got the whole
portable character set (and then some) in the first 128 codepoints,
which have the ASCII code as both octet SBCS value and wchar_t value.
In this scenario, is it permissible to map the other 128 codepoints
“high” i.e. to wchar_t values > 0x0100?

I’m reading the standard as yes, but not asking already landed me
in trouble in the past so I’d rather…

Thanks in advance,
//mirabilos
-- 
08:05⎜ mika: Does grml have an tool to read Apple
 ⎜System Log (asl) files? :)
08:08⎜ yeah. /bin/rm. ;)   08:09⎜ hexdump -C
08:31⎜ ft, mrud: *g*