<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Even with a locale (e.g., following a
      call to std::setlocale(LC_ALL, "")), the conversion may be
      silently lossy ;)</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">Tom.</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">On 5/3/19 11:32 AM, Steve Downey wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAJEGDKowu+rkBPsCG4Uar0DK8ugN4x+CC+a==UzcxTNg39TPKQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="auto">Also keep in mind that without a locale using a
        multibyte charset, i.e. not the default "C" locale, conversion
        will be silently lossy. </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Fri, May 3, 2019, 11:26 Tom
          Honermann &lt;<a href="mailto:tom@honermann.net"
            target="_blank" rel="noreferrer" moz-do-not-send="true">tom@honermann.net</a>&gt;
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div bgcolor="#FFFFFF" text="#000000">
            <div
              class="m_1543556410975187681m_2238683992514537845moz-cite-prefix">On
              5/3/19 7:12 AM, Lyberta wrote:<br>
            </div>
            <blockquote type="cite">
              <pre class="m_1543556410975187681m_2238683992514537845moz-quote-pre">So GCC 9 has been released and I'm starting migration to char8_t. The
first question is how to print std::u8string? Since std::cout works in
execution character set I need a way to convert string from UTF-8 to ECS.</pre>
            </blockquote>
            I wish I had a better suggestion for you then std::c8rtomb. 
            JeanHeyd is working on a proposal for modern transcoding
            interfaces.<br>
            <blockquote type="cite">
              <pre class="m_1543556410975187681m_2238683992514537845moz-quote-pre">It looks like the only way is to use std::c8rtomb but the API is very
cryptic and I don't understand it. Can someone provide an example code?</pre>
            </blockquote>
            <p>As far as I know, no one has actually implemented
              std::c8rtomb yet.  It has been on my todo list for a long
              time to contribute an implementation to glibc, but I
              haven't found the time yet.</p>
            <p>c8rtomb is intended to match the existing c16rtomb and
              c32rtomb functions, so inherits design and wording from
              them.  The wording in the C++ standard for c8rtomb is a
              lightly edited copy of the C standard's wording for
              c16rtomb.  That wording is, well, it could be improved.  A
              lot.  I intentionally chose to keep it aligned with the C
              standard so as not to cause confusion for implementors
              (presumably, they have already come to an understanding
              with C's wording).</p>
            <p>I suggest looking at the examples for c16rtomb on <a
                href="http://cppreference.com" rel="noreferrer
                noreferrer" target="_blank" moz-do-not-send="true">cppreference.com</a>.<br>
              - <a
                class="m_1543556410975187681m_2238683992514537845moz-txt-link-freetext"
href="https://en.cppreference.com/w/cpp/string/multibyte/c16rtomb"
                rel="noreferrer noreferrer" target="_blank"
                moz-do-not-send="true">https://en.cppreference.com/w/cpp/string/multibyte/c16rtomb</a><br>
            </p>
            <p>Tom.<br>
            </p>
            <blockquote type="cite"> <br>
              <fieldset
                class="m_1543556410975187681m_2238683992514537845mimeAttachmentHeader"></fieldset>
              <pre class="m_1543556410975187681m_2238683992514537845moz-quote-pre">_______________________________________________
SG16 Unicode mailing list
<a class="m_1543556410975187681m_2238683992514537845moz-txt-link-abbreviated" href="mailto:Unicode@isocpp.open-std.org" rel="noreferrer noreferrer" target="_blank" moz-do-not-send="true">Unicode@isocpp.open-std.org</a>
<a class="m_1543556410975187681m_2238683992514537845moz-txt-link-freetext" href="http://www.open-std.org/mailman/listinfo/unicode" rel="noreferrer noreferrer" target="_blank" moz-do-not-send="true">http://www.open-std.org/mailman/listinfo/unicode</a>
</pre>
            </blockquote>
            <p><br>
            </p>
          </div>
          _______________________________________________<br>
          SG16 Unicode mailing list<br>
          <a href="mailto:Unicode@isocpp.open-std.org" rel="noreferrer
            noreferrer" target="_blank" moz-do-not-send="true">Unicode@isocpp.open-std.org</a><br>
          <a href="http://www.open-std.org/mailman/listinfo/unicode"
            rel="noreferrer noreferrer noreferrer" target="_blank"
            moz-do-not-send="true">http://www.open-std.org/mailman/listinfo/unicode</a><br>
        </blockquote>
      </div>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>