<div dir="ltr">Neither <div><font face="courier new, monospace">char8_t cu = 0xC0; </font><br>or<br><font face="courier new, monospace">std::unicode::utf8_code_unit cu{0xC0}; </font><br>are bits of code that I&#39;m likely to write, except very possibly as test cases. In live code, data is dynamic, and a code_unit, particularly a utf-8 code unit, doesn&#39;t show up in isolation, they show up in sequences, but I fail to see why I&#39;d want a sequence of code_units, as I&#39;m immediately going to have to interpret them into something useful.  What are the operations on a utf8_code_unit? What interfaces does it show up in as a vocabulary type? What is the overhead on it when used in bulk? <br><br>Single code_unit validity isn&#39;t enough to get even well formed utf-8, so a significant part of error handling is still going to be present in processing. <br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 17, 2019 at 6:11 PM Lyberta &lt;<a href="mailto:lyberta@lyberta.net">lyberta@lyberta.net</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Steve Downey:<br>
&gt; What interfaces is utf8_code_unit likely to appear in? I&#39;m not sure I see<br>
&gt; the value in a strong type here, whereas I can see it for code_point and<br>
&gt; scalar_value. I expect most conversion operations to translate from untyped<br>
&gt; raw data, most likely byte, char, or char8_t, directly to code_point or<br>
&gt; scalar_value? There&#39;s some special cases for utf-8 / 16 conversions, but<br>
&gt; those are still likely to be on parts of raw buffers or in the vicinity of<br>
&gt; OS interfaces. At least that&#39;s been my experience.<br>
<br>
The strong type is used to enforce stronger invariants. With dumb types<br>
you can shoot yourself in the foot easily:<br>
<br>
char8_t cu = 0xC0; // Invalid UTF-8 code unit, yet compiles<br>
<br>
char16_t cu1 = 300;<br>
char8_t cu2 = cu1; // Makes no sense, yet compiles<br>
<br>
With my proposal:<br>
<br>
std::unicode::utf8_code_unit cu{0xC0}; // Compile time error<br>
<br>
std::unicode::utf16_code_unit cu1{300};<br>
std::unicode::utf8_code_unit cu2 = cu1; // Compile time error<br>
<br>
Modern C++ is all about strong types. std::chrono doesn&#39;t use dumb types<br>
because that would be a disaster.<br>
<br>
Lastly, charN_t is really really horrible name for a type. We should<br>
remove it from the standard, maybe by 2040 or so.<br>
<br>
Oh right, Niall Douglas asked about other languages. If you gonna have a<br>
&quot;char&quot; type at all, do it right. Do it like Swift where &quot;char&quot; is an<br>
extended grapheme cluster because that is the most meaningful definition<br>
for something so ambiguous as character.<br>
<br>
So when we remove &quot;char&quot; from the language, the users would be able to write<br>
<br>
using char = std::unicode::grapheme_cluster;<br>
<br>
I&#39;m fine with that. But in the user code, not in the standard library.<br>
<br>
_______________________________________________<br>
SG16 Unicode mailing list<br>
<a href="mailto:Unicode@isocpp.open-std.org" target="_blank">Unicode@isocpp.open-std.org</a><br>
<a href="http://www.open-std.org/mailman/listinfo/unicode" rel="noreferrer" target="_blank">http://www.open-std.org/mailman/listinfo/unicode</a><br>
</blockquote></div>