<div dir="ltr">Hello<div><br></div><div>It is clear that one of the challenge face by SG-16 is to do utf8 I/O in a system very much not designed for Unicode.</div><div><br></div><div>I distinguish 2 classes of I/O</div><div><ul><li>Run-time I/O</li><li>Compile time I/O, aka text embedded in source file </li></ul></div><div> </div><div>Run-time I/O is a complicated topic that I personally think will only be solved by a careful redesign of the io and locales facilities... but its a much larger discussion,<br></div><div>I actually want to discuss compile time I/O aka string and characters literals.</div><div><br></div><div>It&#39;s a problem complicated enough that it was one of the reasons Python operated a language break that people are still enduring over after a decade. Let&#39;s assume C++ doesn&#39;t want to go that route.</div><div><br></div><div>Let&#39;s further assume</div><div><ul><li>Unicode will not be replaced and superseded in our lifetime</li><li>Unicode is the only character set to be able to handle text for it is the only encoding that is a strict super of all previously existing encodings and strives to encompass all characters used by people</li><li>A poor Unicode support at the language and system levels has led to most developers having a poor understanding of text and encoding (regardless of skill level)</li><li>In many cases developers and engineers only care about sequences of bytes they can pronounce rather than text, and in these cases ASCII is sufficient</li><li>Systems and compiler vendors have a vested interest in supporting Unicode which is already the most used encoding in user-facing systems <a href="https://en.wikipedia.org/wiki/Unicode#Adoption">https://en.wikipedia.org/wiki/Unicode#Adoption</a> </li></ul></div><div>I propose that we work towards making Unicode the only supported _source_ character set - I realize this might take time as far from all source files are encoded in a UTF encoding, however Unicode is designed to make that possible.</div><div>This is also standard practice and both GCC and Clang will assume a UTF-8 encoding</div><div><br></div><div>In the meantime, I propose that:</div><div><ul><li>Source with characters outside of the basic source character set embedded in a utf-8, utf-16 or utf-32 character or string literal are ill-formed<b> if and only if</b> the source/input character set is not Unicode.</li><li>We put out a guideline recommending for source files to be utf-8 encoded</li><li>We put in the standard that compiler should assume utf8-encoded filers as the default input encoding unless of the existence of implementation defined out-of-band information (which would have no practical impact, but to signal we recommend supporting utf-8)</li><li>We deprecate string and wide character and string literals (char, wchar_t) whose source representation contains characters not re-presentable in the basic execution character set or wide execution character set  respectively. We encourage implementers to emit a warning in these cases - the intent is to avoid loss of information when transcoding to the execution character set - This matches existing practice</li></ul><div><br></div></div><div>The proposed changes hope to make it easier to use string literals and Unicode strings literal without loss of information portably across platforms by capitalizing on char8_t </div><div>They would standardize existing practice, match common practice in other languages (go rust, swift, python) and avoid bugs related to loss of information when transcoding arbitrary Unicode data to legacy encodings not able to represent but a very small of characters defined by Unicode.  </div><div><br></div><div>It also make it feasible to have Unicode identifiers in the future, as proposed by JF </div><div><br></div><div>Looking to discussing these ideas further,</div><div>Corentin</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>