Closed GabrielRavier closed 4 days ago
PS: Running my example on an ASAN build of cosmopolitan also results in the following being output:
cosmopolitan: WARNING: ASAN bad 4 byte load at 7000007ffd14 bt 473a8b 46a1c7 467fe0
so there's probably also a problem there.
Looks like this is an intended divergence from the standard (well except for the ASAN error but that's not a thing in cosmopolitan anymore), so I'll close this.
The following program:
outputs
< π>
(with a single space) on the 3 libcs I tested it on (when using an appropriate UTF-8 locale to ensure the conversion from wint_t would work properly), whereas cosmopolitan instead outputs< π>
(with two spaces).As the C standard indicates that field length is counted in bytes and not in multibyte characters, cosmopolitan's behavior is incorrect.
The standard makes this clear by including the following example:
If the field length was to be counted in multi-byte characters rather than in bytes, the output of the example given in the standard would be quite different.