<div dir="auto">Oh dear. Does JSON specify locale for floating point. <div dir="auto"><br></div><div dir="auto">And this is why LC_ALL=C is common in scripts that have to run in hostile environments, like France, isn&#39;t it. It&#39;s been too long. </div><div dir="auto"><br></div><div dir="auto">Our internal internationalization apis don&#39;t use locale, and are almost always explicit. Does occasionally lead to failure on remembering what the input format was. Now that almost everything is Unicode we have fewer problems. </div><div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Sep 7, 2019, 12:44 Thiago Macieira &lt;<a href="mailto:thiago@macieira.org">thiago@macieira.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Saturday, 7 September 2019 08:26:00 PDT Lyberta wrote:<br>
&gt; Thiago Macieira:<br>
&gt; &gt; On Friday, 6 September 2019 19:17:00 PDT Lyberta wrote:<br>
&gt; &gt;&gt; I think if the machine-readable output depends on locale, the author of<br>
&gt; &gt;&gt; the program seriously messed up.<br>
&gt; &gt; <br>
&gt; &gt; Oh, I agree with you. The problem is that the standard C library (as<br>
&gt; &gt; extended by POSIX) does not provide the API to make that happen *and*<br>
&gt; &gt; support internationalisation. And that&#39;s assuming the tool even have a<br>
&gt; &gt; &quot;machine readable&quot; format in the first place. In the Unix tradition, you<br>
&gt; &gt; just scrape the output of tools.<br>
&gt; <br>
&gt; Then don&#39;t use standard C library. On POSIX use open(), read() and<br>
&gt; write(), have your own Unicode layer on top and read/write UTF-8 JSON if<br>
&gt; you want to output anything machine-readable.<br>
<br>
Challenge: produce this JSON thread-safely in machine-readable format in C, <br>
with setlocale(LC_ALL, &quot;&quot;); at the top of the file, from input double v = 1.1.<br>
<br>
 [ 1.1 ]<br>
<br>
<br>
&gt; There is no such thing as plain text and Unix philosophy is dead.<br>
<br>
Great! Let&#39;s drop JSON then.<br>
<br>
&gt; I have a C++ proposal for binary IO/serialization here:<br>
&gt; <br>
&gt; <a href="https://github.com/Lyberta/cpp-io" rel="noreferrer noreferrer" target="_blank">https://github.com/Lyberta/cpp-io</a><br>
&gt; <br>
&gt; It was already reviewed by Niall twice and hopefully by C++23 we&#39;ll have<br>
&gt; sane binary IO in the standard. I don&#39;t have to plans to fix C at this<br>
&gt; point though because it doesn&#39;t have an analog of std::byte yet.<br>
<br>
That looks very nice, aside from the obligatory bike-shedding of the class and <br>
namespace names, of course.<br>
<br>
&gt; &gt; But the input is not Unicode, it&#39;s file paths. On Unix, it is possible to<br>
&gt; &gt; pass binary input in the command-line. With some effort, you can even<br>
&gt; &gt; pass NULs to specially crafted receiver applications. The std::filesystem<br>
&gt; &gt; API appears to have a way to retrieve the native raw format, which some<br>
&gt; &gt; application may need.<br>
&gt; Yeah, it&#39;s all because C decided to have char as both bytes and<br>
&gt; characters and doomed us all for ~50 years of pain. We need to decide if<br>
&gt; main() should get text or characters and fix it.<br>
<br>
I think the decision was made for us: bytes on Unix, bytes on Windows if Niall <br>
can get the runtimes to use UTF-8, wchar_t otherwise.<br>
<br>
-- <br>
Thiago Macieira - thiago (AT) <a href="http://macieira.info" rel="noreferrer noreferrer" target="_blank">macieira.info</a> - thiago (AT) <a href="http://kde.org" rel="noreferrer noreferrer" target="_blank">kde.org</a><br>
   Software Architect - Intel System Software Products<br>
<br>
<br>
<br>
_______________________________________________<br>
SG16 Unicode mailing list<br>
<a href="mailto:Unicode@isocpp.open-std.org" target="_blank" rel="noreferrer">Unicode@isocpp.open-std.org</a><br>
<a href="http://www.open-std.org/mailman/listinfo/unicode" rel="noreferrer noreferrer" target="_blank">http://www.open-std.org/mailman/listinfo/unicode</a><br>
</blockquote></div>