<html><head></head><body bgcolor="#FFFFFF" text="#000000" lang="en-US" style="background-color: rgb(255, 255, 255); line-height: initial;">                                                                                      <div style="width: 100%; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);">I think we would want it to be measured in glyphs. </div><div style="width: 100%; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);">Are you suggesting code points because glyphs are too hard?</div><div style="width: 100%; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);">Should we specify glyphs anyhow and leave it to QoI?</div>                                                                                                                                     <div style="width: 100%; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);"><br style="display:initial"></div>                                                                                                                                                                                                   <div style="font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);">Sent&nbsp;from&nbsp;my&nbsp;BlackBerry&nbsp;portable&nbsp;Babbage&nbsp;Device</div>                                                                                                                                                                                  <table width="100%" style="background-color:white;border-spacing:0px;"> <tbody><tr><td colspan="2" style="font-size: initial; text-align: initial; background-color: rgb(255, 255, 255);">                           <div style="border-style: solid none none; border-top-color: rgb(181, 196, 223); border-top-width: 1pt; padding: 3pt 0in 0in; font-family: Tahoma, 'BB Alpha Sans', 'Slate Pro'; font-size: 10pt;">  <div><b>From: </b>Tom Honermann via Lib</div><div><b>Sent: </b>Saturday, September 7, 2019 8:13 PM</div><div><b>To: </b>Library Working Group; unicode@isocpp.open-std.org</div><div><b>Reply To: </b>lib@lists.isocpp.org</div><div><b>Cc: </b>Tom Honermann</div><div><b>Subject: </b>[isocpp-lib] New issue: Are std::format field widths code units, code points, or something else?</div></div></td></tr></tbody></table><div style="border-style: solid none none; border-top-color: rgb(186, 188, 209); border-top-width: 1pt; font-size: initial; text-align: initial; background-color: rgb(255, 255, 255);"></div><br><div id="_originalContent" style="background-color: rgb(255, 255, 255);">
  

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  
  
    <p><a moz-do-not-send="true" href="http://eel.is/c++draft/format#string.std-7">[format.string.std]p7</a>
      states:</p>
    <p>
      </p><blockquote type="cite">
        <p>The <i>positive-integer</i> in <i>width</i> is a decimal
          integer defining the minimum field width.&nbsp; If <i>width</i> is
          not specified, there is no minimum field width, and the field
          width is determined based on the content of the field.</p>
      </blockquote>
    <p></p>
    <p>Is field width measured in code units, code points, or something
      else?</p>
    <p>Consider the following example assuming a UTF-8 locale:<br>
    </p>
    <p><tt>std::format("{}", "\xC3\x81");&nbsp;&nbsp;&nbsp;&nbsp; // U+00C1</tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        { </tt><tt>LATIN CAPITAL LETTER A WITH ACUTE }</tt><br>
      <tt>std::format("{}", "\x41\xCC\x81"); // U+0041 U+0301 { </tt><tt>LATIN
        CAPITAL LETTER A } { </tt><tt>COMBINING ACUTE ACCENT }<br>
      </tt></p>
    <p>In both cases, the arguments encode the same user-perceived
      character (Á).&nbsp; The first uses two UTF-8 code units to encode a
      single code point that represents a single glyph using a composed
      Unicode normalization form.&nbsp; The second uses three code units to
      encode two code points that represent the same glyph using a
      decomposed Unicode normalization form.</p>
    <p>How is the field width determined?&nbsp; If measured in code units,
      the first has a width of 2 and the second of 3.&nbsp; If measured in
      code points, the first has a width of 1 and the second of 2.&nbsp; If
      measured in grapheme clusters, both have a width of 1.&nbsp; Is the
      determination locale dependent?</p>
    <p><b>Proposed resolution:</b></p>
    <p>Field widths are measured in code units and are not locale
      dependent. Modify <a moz-do-not-send="true" href="http://eel.is/c++draft/format#string.std-7">[format.string.std]p7</a>
      as follows:</p>
    <p> </p>
    <blockquote type="cite">
      <p>The <i>positive-integer</i> in <i>width</i> is a decimal
        integer defining the minimum field width.&nbsp; If <i>width</i> is
        not specified, there is no minimum field width, and the field
        width is determined based on the content of the field.&nbsp; <b><font color="#33cc00">Field width is measured in code units.&nbsp; Each
            byte of a multibyte character contributes to the field
            width.</font></b><br>
      </p>
    </blockquote>
    <p>(<i>code unit</i> is not formally defined in the standard.&nbsp; Most
      uses occur in UTF-8 and UTF-16 specific contexts, but <a moz-do-not-send="true" href="http://eel.is/c++draft/lex.ext#5">[lex.ext]p5</a>
      uses it in an encoding agnostic context.)<br>
    </p>
    <p>Tom.<br>
    </p>
  

<br><!--end of _originalContent --></div></body></html>