Re: Announcing start of WTL10

"Nenad Stefanović [email protected] [wtl]" <[email protected]> Thu, 28 Sep 2017 02:08:22 +0200
Newsgroups gmane.comp.windows.wtl
Message-ID <CAK3Hp+8brMB3yBkRNBwo4WXFfn5rhJ9rF-h1Thrw6+B_wst8hA@mail.gmail.com>
--001a114a8534e65ae1055a34b4fa
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Thanks, Konstantin


On Wed, Sep 27, 2017 at 7:45 AM, 'Konstantin Mironovich' [email protected]
[wtl] <[email protected]> wrote:

>
>
> =EF=BB=BF
> Hi gentlefolks,
>
> Nenad,
> in our project we also use std::wstring and Qt
> please look at QString http://doc.qt.io/qt-5/qstring.html
> it has some useful stuff like toStdString(), toStdWString(), etc
>
> Konstantin
>
>
> -km
>
> ----- Original Message -----
> *From:* Nenad Stefanovi=C4=87 [email protected] [wtl]
> <[email protected]+[wtl]>
> *To:* [email protected]
> *Sent:* Wednesday, September 27, 2017 1:25 AM
> *Subject:* Re: [wtl] Announcing start of WTL10
>
>
>
> Hi Jim,
>
> Thank you for the analysis and suggestions.
>
> Your own implementation shows how easy it is to use std::string with WTL
> without adding any direct support for it. I am still listening to all
> arguments and suggestions.
>
> Cheers,
> Nenad
>
>
> On Tue, Sep 26, 2017 at 5:41 PM, Jim Barry [email protected] [wtl] <
> [email protected]> wrote:
>
>>
>>
>> Hi Nenad,
>>
>> I think it would be good to support std::string. However, it is perhaps
>> not quite as straightforward as it might seem.
>>
>> I have added some std::string support to my local copy of WTL. I strongl=
y
>> adhere to the "UTF-8 Everywhere" philosophy (see
>> http://utf8everywhere.org/) where every std::string is considered to be
>> UTF-8 encoded, and std::wstring is not used except for performing
>> wide/narrow conversions at API boundaries.
>>
>> So, for example, std::string wrappers for Get/SetWindowText look
>> something like this:
>>
>> void SetWindowText(std::string const & text)
>> {
>>     SetWindowText(widen(text).c_str());
>> }
>>
>> std::string GetWindowText() const
>> {
>>     ATL::CString str;
>>     GetWindowText(str);
>>     return narrow(str);
>> }
>>
>> The "get" wrapper delegates to the CString version, partly for
>> convenience, and also because the non-const version of std::string::data=
()
>> is only available since C++17.
>>
>> I suppose that some people are still going to want to use std::wstring,
>> which presents a difficulty with the "get" wrappers, since functions can=
't
>> be overloaded on return type. A shim type could be returned (offering
>> user-defined conversions to std::string/wstring) but this approach has s=
ome
>> problems.
>>
>> Otherwise, if both std::string and std::wstring support is required, the=
n
>> out-parameters must be used:
>>
>> BOOL SetWindowText(std::string const & text);
>> BOOL SetWindowText(std::wstring const & text);
>> int GetWindowText(std::string & text);
>> int GetWindowText(std::wstring & text);
>>
>> Which, if nothing else, is in keeping with the existing WTL style.
>>
>> This is all assuming a Unicode build. ANSI flavours of WinAPI functions
>> (e.g. GetWindowTextA) don't understand UTF-8 so it makes little sense fo=
r
>> Unicode strings to exist in an ANSI build.
>>
>> Thoughts?
>>
>>
>> On 22 September 2017 at 01:27, Nenad Stefanovi=C4=87 [email protected]
>> [wtl] <[email protected]> wrote:
>> >
>> >
>> >
>> > Hi Jeff,
>> >
>> > That can be done, depending on how many people are requesting it. Sinc=
e
>> WTL already uses CString, you can simply copy values from CString to
>> std:string in your code.
>> >
>> > I hope that others can reply to this thread if they think that direct
>> use of std:string/wstring is needed.
>> >
>> > Cheers,
>> > Nenad
>>
>>
>=20
>

--001a114a8534e65ae1055a34b4fa
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable





<head>

<style type=3D"text/css">
<!--

/* start of attachment style */
       .ygrp-photo-title{
         clear: both;
         font-size: smaller;
         height: 15px;
         overflow: hidden;
         text-align: center;
         width: 75px;
       }
       div.ygrp-photo{
         background-position: center;
         background-repeat: no-repeat;
         background-color: white;
         border: 1px solid black;
         height: 62px;
         width: 62px;
       }

       div.photo-title=20
         a,
         div.photo-title a:active,
         div.photo-title a:hover,
         div.photo-title a:visited {
           text-decoration: none;=20
       }

       div.attach-table div.attach-row {
         clear: both;
       }

       div.attach-table div.attach-row div {
         float: left;
         /* margin: 2px;*/
       }

       p {
         clear: both;
         padding: 15px 0 3px 0;
	 overflow: hidden;
       }

       div.ygrp-file {
         width: 30px;
         valign: middle;
       }
       div.attach-table div.attach-row div div a {
         text-decoration: none;
       }

       div.attach-table div.attach-row div div span {
         font-weight: normal;
       }

       div.ygrp-file-title {
         font-weight: bold;
       }
 /* end of attachment style */
        -->
        </style>
        </head>
<html>
<head>
<style type=3D"text/css">
<!--
#ygrp-mkp {
  border: 1px solid #d8d8d8;
  font-family: Arial;
  margin: 10px 0;
  padding: 0 10px;
}

#ygrp-mkp hr {
  border: 1px solid #d8d8d8;
}

#ygrp-mkp #hd {
  color: #628c2a;
  font-size: 85%;
  font-weight: 700;
  line-height: 122%;
  margin: 10px 0;
}

#ygrp-mkp #ads {
  margin-bottom: 10px;
}

#ygrp-mkp .ad {
  padding: 0 0;
}

#ygrp-mkp .ad p {
  margin: 0;
}

#ygrp-mkp .ad a {
  color: #0000ff;
  text-decoration: none;
}
-->
</style>
</head>
<body>



<!-- |**|begin egp html banner|**| -->

<br><br>

<!-- |**|end egp html banner|**| -->


<div dir=3D"ltr">Thanks,=C2=A0<span style=3D"font-family:Arial,helvetica,cl=
ean,sans-serif;font-size:13px">Konstantin</span><div><br></div></div><div c=
lass=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, Sep 27, 2017 at=
 7:45 AM, &#39;Konstantin Mironovich&#39; <a href=3D"mailto:[email protected]"=
>[email protected]</a> [wtl] <span dir=3D"ltr">&lt;<a href=3D"mailto:wtl@yahoo=
groups.com" target=3D"_blank">[email protected]</a>&gt;</span> wrote:<br>=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">


<u></u>









=20
<div style=3D"background-color:#fff">
<span style=3D"display:none">=C2=A0</span>


<div id=3D"m_8501446939532124814ygrp-mlmsg">
  <div id=3D"m_8501446939532124814ygrp-msg">


    <div id=3D"m_8501446939532124814ygrp-text">
=20=20=20=20=20=20
=20=20=20=20=20=20
      <p>=EF=BB=BF<u></u>


</p><div><font face=3D"Calibri">Hi gentlefolks,</font></div>
<div><font face=3D"Calibri"></font>=C2=A0</div>
<div><font face=3D"Calibri">Nenad,</font></div>
<div><font face=3D"Calibri">in our project we also use std::wstring and=20
Qt</font></div>
<div><font face=3D"Calibri">please look at QString <a href=3D"http://doc.qt=
.io/qt-5/qstring.html" target=3D"_blank">http://doc.qt.io/qt-5/qstring.<wbr=
>html</a></font></div>
<div><font face=3D"Calibri">it has some useful stuff like toStdString(),=20
toStdWString(), etc</font></div>
<div><font face=3D"Calibri"></font>=C2=A0</div>
<div><font face=3D"Calibri">Konstantin</font></div>
<div><font face=3D"Calibri"></font>=C2=A0</div>
<div><font face=3D"Calibri"></font>=C2=A0</div>
<div><font size=3D"2">-km<br></font></div>
<blockquote style=3D"BORDER-LEFT:#000000 2px solid;MARGIN-LEFT:5px;MARGIN-R=
IGHT:0px"><span class=3D"">
  <div style=3D"FONT:10pt arial">----- Original Message ----- </div>
  <div style=3D"FONT:10pt arial;BACKGROUND:#e4e4e4"><b>From:</b>=20
  <a title=3D"[email protected]" href=3D"mailto:[email protected]+[wtl]=
" target=3D"_blank">Nenad=20
  Stefanovi=C4=87 [email protected] [wtl]</a> </div>
  </span><div><div class=3D"h5"><div style=3D"FONT:10pt arial"><b>To:</b> <=
a title=3D"[email protected]" href=3D"mailto:[email protected]" target=
=3D"_blank">[email protected]</a> </div>
  <div style=3D"FONT:10pt arial"><b>Sent:</b> Wednesday, September 27, 2017=
 1:25=20
  AM</div>
  <div style=3D"FONT:10pt arial"><b>Subject:</b> Re: [wtl] Announcing start=
 of=20
  WTL10</div>
  <div><br></div><span>=C2=A0</span>=20
  <div id=3D"m_8501446939532124814ygrp-text">
  <p>
  </p><div dir=3D"ltr">Hi Jim,
  <div><br></div>
  <div>Thank you for the analysis and suggestions.</div>
  <div><br></div>
  <div>Your own implementation shows how easy it is to use std::string with=
 WTL=20
  without adding any direct support for it. I am still listening to all=20
  arguments and suggestions.</div>
  <div><br></div>
  <div>Cheers,</div>
  <div>Nenad</div>
  <div><br></div></div>
  <div class=3D"gmail_extra"><br>
  <div class=3D"gmail_quote">On Tue, Sep 26, 2017 at 5:41 PM, Jim Barry <a =
href=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a> [wt=
l] <span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=3D"_=
blank">[email protected]</a>&gt;</span> wrote:<br>
  <blockquote style=3D"BORDER-LEFT:#ccc 1px solid" class=3D"gmail_quote"><u=
></u>
    <div style=3D"BACKGROUND-COLOR:#fff"><span>=C2=A0</span>=20
    <div id=3D"m_8501446939532124814m_-455343694678785389ygrp-mlmsg">
    <div id=3D"m_8501446939532124814m_-455343694678785389ygrp-msg">
    <div id=3D"m_8501446939532124814m_-455343694678785389ygrp-text">
    <p></p>
    <div dir=3D"ltr">Hi Nenad,<br><br>I think it would be good to support=20
    std::string. However, it is perhaps not quite as straightforward as it =
might=20
    seem.<br><br>I have added some std::string support to my local copy of =
WTL.=20
    I strongly adhere to the &quot;UTF-8 Everywhere&quot; philosophy (see <=
a href=3D"http://utf8everywhere.org/" target=3D"_blank">http://utf8everywhe=
re.org/</a>) where every std::string is=20
    considered to be UTF-8 encoded, and std::wstring is not used except for=
=20
    performing wide/narrow conversions at API boundaries.<br><br>So, for=20
    example, std::string wrappers for Get/SetWindowText look something like=
=20
    this:<br><br>
    <div><span style=3D"FONT-FAMILY:monospace,monospace">void=20
    SetWindowText(std::string const &amp; text)</span><br></div><font face=
=3D"monospace, monospace">{<br>=C2=A0 =C2=A0=20
    SetWindowText(widen(text).c_st<wbr>r());<br>}<br><br>std::string=20
    GetWindowText() const<br>{<br>=C2=A0 =C2=A0 ATL::CString str;<br>=C2=A0=
=20
    =C2=A0 GetWindowText(str);<br>=C2=A0 =C2=A0 return=20
    narrow(str);<br>}<br></font><br>The &quot;get&quot; wrapper delegates t=
o the CString=20
    version, partly for convenience, and also because the non-const version=
 of=20
    std::string::data() is only available since C++17.<br><br>I suppose tha=
t=20
    some people are still going to want to use std::wstring, which presents=
 a=20
    difficulty with the &quot;get&quot; wrappers, since functions can&#39;t=
 be overloaded on=20
    return type. A shim type could be returned (offering user-defined=20
    conversions to std::string/wstring) but this approach has some=20
    problems.<br><br>Otherwise, if both std::string and std::wstring suppor=
t is=20
    required, then out-parameters must be used:<br><br><font face=3D"monosp=
ace, monospace">BOOL SetWindowText(std::string const &amp;=20
    text);<br>BOOL SetWindowText(std::wstring const &amp; text);<br>int=20
    GetWindowText(std::string &amp; text);<br>int GetWindowText(std::wstrin=
g=20
    &amp; text);</font>
    <div><br></div>
    <div>Which, if nothing else, is in keeping with the existing WTL=20
style.</div>
    <div><br></div>
    <div>This is all assuming a Unicode build. ANSI flavours of WinAPI func=
tions=20
    (e.g. GetWindowTextA) don&#39;t understand UTF-8 so it makes little sen=
se for=20
    Unicode strings to exist in an ANSI build.=C2=A0</div>
    <div><br></div>
    <div>Thoughts?</div><span>
    <div><br><br>On 22 September 2017 at 01:27, Nenad Stefanovi=C4=87 <a hr=
ef=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>=
=20
    [wtl] &lt;<a href=3D"mailto:[email protected]" target=3D"_blank">wtl@=
yahoogroups.com</a>&gt;=20
    wrote:<br>&gt;<br>&gt;<br>&gt;<br>&gt; Hi Jeff,<br>&gt;<br>&gt; That ca=
n be=20
    done, depending on how many people are requesting it. Since WTL already=
 uses=20
    CString, you can simply copy values from CString to std:string in your=
=20
    code.<br>&gt;<br>&gt; I hope that others can reply to this thread if th=
ey=20
    think that direct use of std:string/wstring is needed.<br>&gt;<br>&gt;=
=20
    Cheers,<br>&gt; Nenad</div></span></div>
    <p></p></div>
    <div style=3D"HEIGHT:0px;COLOR:#fff"></div></div></div></div></blockquo=
te></div><br></div>
  <p></p><p></p></div>
</div></div></blockquote><p></p>

    </div>
=20=20=20=20=20

=20=20=20=20
    <div style=3D"color:#fff;height:0"></div>


</div>



=20=20






</blockquote></div><br></div>




<!-- |**|begin egp html banner|**| -->

<br>


<br>

<!-- |**|end egp html banner|**| -->


<div width=3D"1" style=3D"color: white; clear: both;"/>__._,_.___</div>

=20=20=20=20=20=20
=20=20

=20=20=20=20
    <div id=3D"fromDMARC" style=3D"clear:both; margin-top: 10px;">
         <hr style=3D"height:2px ; border-width:0; color:#E3E3E3; backgroun=
d-color:#E3E3E3;">
         Posted by: =3D?UTF-8?Q?Nenad_Stefanovi=3DC4=3D87?=3D &lt;nenad2001=
@gmail.com&gt;         <hr style=3D"height:2px ; border-width:0; color:#E3E=
3E3; background-color:#E3E3E3;">
    </div>
<!-- Start Recommendations -->
<!-- End Recommendations -->



<!-- |**|begin egp html banner|**| -->

  <img src=3D"http://geo.yahoo.com/serv?s=3D97476590/grpId=3D488621/grpspId=
=3D1705006764/msgId=3D16755/stime=3D1506557365" width=3D"1" height=3D"1"> <=
br>

<!-- |**|end egp html banner|**| -->

=20=20
<!-- |**|begin egp html banner|**| -->

<br>



=20=20=20
=20=20=20=20=20
=20
        <!-- |**|begin egp html banner|**| -->
        <div id=3D"ygrp-vital" style=3D"background-color: #f2f2f2; font-fam=
ily: Verdana; font-size: 10px; margin-bottom: 10px; padding: 10px;">

        <span id=3D"vithd" style=3D"font-weight: bold; color: #333; text-tr=
ansform: uppercase; "><a href=3D"https://groups.yahoo.com/neo/groups/wtl/in=
fo;_ylc=3DX3oDMTJkZTJmMHE4BF9TAzk3MzU5NzE0BGdycElkAzQ4ODYyMQRncnBzcElkAzE3M=
DUwMDY3NjQEc2VjA3Z0bARzbGsDdmdocARzdGltZQMxNTA2NTU3MzY1" style=3D"text-deco=
ration: none;">Visit Your Group</a></span>

     <ul style=3D"list-style-type: none; margin: 0; padding: 0; display: in=
line;">
                                                    </ul>
  </div>


<div id=3D"ft" style=3D"font-family: Arial; font-size: 11px; margin-top: 5p=
x; padding: 0 2px 0 0; clear: both;">
  <a href=3D"https://groups.yahoo.com/neo;_ylc=3DX3oDMTJjbzl0dmIzBF9TAzk3ND=
c2NTkwBGdycElkAzQ4ODYyMQRncnBzcElkAzE3MDUwMDY3NjQEc2VjA2Z0cgRzbGsDZ2ZwBHN0a=
W1lAzE1MDY1NTczNjU-" style=3D"float: left;"><img src=3D"http://l.yimg.com/r=
u/static/images/yg/img/email/new_logo/logo-groups-137x15.png" height=3D"15"=
 width=3D"137" alt=3D"Yahoo! Groups" style=3D"border: 0;"/></a>
  <div style=3D"color: #747575; float: right;"> &bull; <a href=3D"https://i=
nfo.yahoo.com/privacy/us/yahoo/groups/details.html" style=3D"text-decoratio=
n: none;">Privacy</a> &bull; <a href=3D"mailto:wtl-unsubscribe@yahoogroups.=
com?subject=3DUnsubscribe" style=3D"text-decoration: none;">Unsubscribe</a>=
 &bull; <a href=3D"https://info.yahoo.com/legal/us/yahoo/utos/terms/" style=
=3D"text-decoration: none;">Terms of Use</a> </div>
</div>

<!-- |**|end egp html banner|**| -->

  </div> <!-- ygrp-msg -->

=20=20=20


  <br>

<!-- |**|end egp html banner|**| -->


<div style=3D"color: white; clear: both;"/>__,_._,___</div>
</body>

</html>

--001a114a8534e65ae1055a34b4fa--