[SG16-Unicode] P1689: Encoding of filenames for interchange

Lyberta lyberta at lyberta.net
Sun Sep 8 05:31:00 CEST 2019


Thiago Macieira:
> Challenge: produce this JSON thread-safely in machine-readable format in C, 
> with setlocale(LC_ALL, ""); at the top of the file, from input double v = 1.1.
> 
>  [ 1.1 ]

In C, huh? I'd rather write in C++ and in that case it's not that hard
because of std::mutex, char8_t, std::byte, templates.

I'm not sure why setlocale was mentioned, why would you ever format JSON
numbers (or anything JSON) with locale?

> Great! Let's drop JSON then.

JSON requires UTF-8 and specific parsing rules, it far away from plain text.

>> Yeah, it's all because C decided to have char as both bytes and
>> characters and doomed us all for ~50 years of pain. We need to decide if
>> main() should get text or characters and fix it.
> 
> I think the decision was made for us: bytes on Unix, bytes on Windows if Niall 
> can get the runtimes to use UTF-8, wchar_t otherwise.
> 

I'm saying change the signature of main(). If it's text then:

int main(std::span<std::unicode::text_view> args);

If it's bytes then:

int main(std::span<std::span<std::byte>> args);

Or why not the the user decide? The C++ runtime would do the conversion
anyway.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
Url : http://www.open-std.org/pipermail/unicode/attachments/20190908/39fa496f/attachment.bin 


More information about the Unicode mailing list