<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 9/7/19 8:27 PM, Tony V E wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:20190908002724.5218384.37561.86238@gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <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>
    </blockquote>
    I agree that would be ideal, but...<br>
    <blockquote type="cite"
      cite="mid:20190908002724.5218384.37561.86238@gmail.com">
      <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>
    </blockquote>
    I don't know how to achieve that.  Field width doesn't really work
    for alignment unless one assumes a monospace font.  We could measure
    in terms of extended grapheme clusters, but EGCS width has changed
    over time (e.g., family emoji).  That makes alignment dependent on
    both display properties and Unicode version.  And, of course, this
    would drag in locale dependence as well.
    <blockquote type="cite"
      cite="mid:20190908002724.5218384.37561.86238@gmail.com">
      <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>
    </blockquote>
    <p>Perhaps we could (I'm not sure how to specify that), but then we
      end up with the locale dependency, at least for char and wchar_t
      (which is all that is supported right now).<br>
    </p>
    <p>Tom.</p>
    <blockquote type="cite"
      cite="mid:20190908002724.5218384.37561.86238@gmail.com">
      <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 from my BlackBerry portable Babbage Device</div>
      <table style="background-color:white;border-spacing:0px;"
        width="100%">
        <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;
                  <a class="moz-txt-link-abbreviated" href="mailto:unicode@isocpp.open-std.org">unicode@isocpp.open-std.org</a></div>
                <div><b>Reply To: </b><a class="moz-txt-link-abbreviated" href="mailto:lib@lists.isocpp.org">lib@lists.isocpp.org</a></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>
      <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.  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>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");     // U+00C1</tt><tt>       
            { </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 (Á).  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.  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?  If measured in code
          units, the first has a width of 2 and the second of 3.  If
          measured in code points, the first has a width of 1 and the
          second of 2.  If measured in grapheme clusters, both have a
          width of 1.  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.  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.  <b><font color="#33cc00">Field width is measured in
                code units.  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. 
          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>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>