C++ Logo

sg16

Advanced search

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

From: Lyberta <lyberta_at_[hidden]>
Date: Sun, 08 Sep 2019 03:31:00 +0000
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.


Received on 2019-09-08 05:32:01