<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Aus std::string einen std::wstring machen]]></title><description><![CDATA[<p>Hallo Forum,</p>
<p>ich muss einer C++ Visual Studio 6 DLL ein wstring übergeben. Leider arbeitet mein Programm nur mit string. Wie kann ich dazwischen konvertieren? In der FAQ habe ich schon den char -&gt; char_t Artikel gefunden. Dort steht:</p>
<pre><code class="language-cpp">// andere
char Narrow[6] = &quot;Hallo&quot;;
wchar_t Widen[6];
use_facet&lt;ctype&lt;wchar_t&gt;&gt; (cout.getloc()).widen(Narrow, Narrow+6, Widen);
</code></pre>
<p>Das ist zum einen umständlich, zum anderen habe ich eine Menge Fehlermeldungen wenn ich den Source so einfüge:</p>
<blockquote>
<p>error C2780: 'const _F &amp;__cdecl std::use_facet(const class std::locale &amp;,const _F *,bool)' : expects 3 arguments - 1 provided<br />
c:\program files\microsoft visual studio\vc98\include\xlocale(157) : see declaration of 'use_facet'<br />
error C2228: left of '.widen' must have class/struct/union type<br />
error C2563: mismatch in formal parameter list<br />
error C2568: '=' : unable to resolve function overload<br />
could be 'class std::basic_istream&lt;unsigned short,struct std::char_traits&lt;unsigned short&gt; &gt; &amp;__cdecl std::ws(class std::basic_istream&lt;unsigned short,struct std::char_traits&lt;unsigned short&gt; &gt; &amp;)'<br />
c:\program files\microsoft visual studio\vc98\include\istream(560) : see declaration of 'ws'<br />
or 'class std::basic_istream&lt;char,struct std::char_traits&lt;char&gt; &gt; &amp;__cdecl std::ws(class std::basic_istream&lt;char,struct std::char_traits&lt;char&gt; &gt; &amp;)'<br />
c:\program files\microsoft visual studio\vc98\include\istream(540) : see declaration of 'ws'<br />
or 'class std::basic_istream&lt;_E,_Tr&gt; &amp;__cdecl std::ws(class std::basic_istream&lt;_E,_Tr&gt; &amp;)'<br />
c:\program files\microsoft visual studio\vc98\include\istream(520) : see declaration of 'ws'<br />
Error executing cl.exe.</p>
</blockquote>
<p>Solche Probleme sind bestimmt schon öfters aufgetaucht. Gibt es da nichts einfacheres? Notfalls muß ich mir halt mbstowcs() von der WinApi ansehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/182395/aus-std-string-einen-std-wstring-machen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 20:30:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/182395.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 24 May 2007 15:34:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Aus std::string einen std::wstring machen on Thu, 24 May 2007 15:34:58 GMT]]></title><description><![CDATA[<p>Hallo Forum,</p>
<p>ich muss einer C++ Visual Studio 6 DLL ein wstring übergeben. Leider arbeitet mein Programm nur mit string. Wie kann ich dazwischen konvertieren? In der FAQ habe ich schon den char -&gt; char_t Artikel gefunden. Dort steht:</p>
<pre><code class="language-cpp">// andere
char Narrow[6] = &quot;Hallo&quot;;
wchar_t Widen[6];
use_facet&lt;ctype&lt;wchar_t&gt;&gt; (cout.getloc()).widen(Narrow, Narrow+6, Widen);
</code></pre>
<p>Das ist zum einen umständlich, zum anderen habe ich eine Menge Fehlermeldungen wenn ich den Source so einfüge:</p>
<blockquote>
<p>error C2780: 'const _F &amp;__cdecl std::use_facet(const class std::locale &amp;,const _F *,bool)' : expects 3 arguments - 1 provided<br />
c:\program files\microsoft visual studio\vc98\include\xlocale(157) : see declaration of 'use_facet'<br />
error C2228: left of '.widen' must have class/struct/union type<br />
error C2563: mismatch in formal parameter list<br />
error C2568: '=' : unable to resolve function overload<br />
could be 'class std::basic_istream&lt;unsigned short,struct std::char_traits&lt;unsigned short&gt; &gt; &amp;__cdecl std::ws(class std::basic_istream&lt;unsigned short,struct std::char_traits&lt;unsigned short&gt; &gt; &amp;)'<br />
c:\program files\microsoft visual studio\vc98\include\istream(560) : see declaration of 'ws'<br />
or 'class std::basic_istream&lt;char,struct std::char_traits&lt;char&gt; &gt; &amp;__cdecl std::ws(class std::basic_istream&lt;char,struct std::char_traits&lt;char&gt; &gt; &amp;)'<br />
c:\program files\microsoft visual studio\vc98\include\istream(540) : see declaration of 'ws'<br />
or 'class std::basic_istream&lt;_E,_Tr&gt; &amp;__cdecl std::ws(class std::basic_istream&lt;_E,_Tr&gt; &amp;)'<br />
c:\program files\microsoft visual studio\vc98\include\istream(520) : see declaration of 'ws'<br />
Error executing cl.exe.</p>
</blockquote>
<p>Solche Probleme sind bestimmt schon öfters aufgetaucht. Gibt es da nichts einfacheres? Notfalls muß ich mir halt mbstowcs() von der WinApi ansehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291502</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291502</guid><dc:creator><![CDATA[Jakata]]></dc:creator><pubDate>Thu, 24 May 2007 15:34:58 GMT</pubDate></item><item><title><![CDATA[Reply to Aus std::string einen std::wstring machen on Thu, 24 May 2007 17:01:53 GMT]]></title><description><![CDATA[<p>Hat sich erledigt. Hab die WinApi genommen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291578</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291578</guid><dc:creator><![CDATA[Jakata]]></dc:creator><pubDate>Thu, 24 May 2007 17:01:53 GMT</pubDate></item><item><title><![CDATA[Reply to Aus std::string einen std::wstring machen on Thu, 24 May 2007 17:04:30 GMT]]></title><description><![CDATA[<p>Jakata schrieb:</p>
<blockquote>
<p>Hat sich erledigt. Hab die WinApi genommen.</p>
</blockquote>
<p>Naja und alternativ halt:</p>
<pre><code class="language-cpp">std::string str(&quot;test&quot;);
std::wstring wstr(str.begin(), str.end());
</code></pre>
<p>gruss<br />
v R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291579</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291579</guid><dc:creator><![CDATA[virtuell Realisticer]]></dc:creator><pubDate>Thu, 24 May 2007 17:04:30 GMT</pubDate></item><item><title><![CDATA[Reply to Aus std::string einen std::wstring machen on Thu, 24 May 2007 18:49:15 GMT]]></title><description><![CDATA[<p>@virtuell Realisticer<br />
keine sehr schöne lösung, sie geht zwar, ist jedoch unflexibel und auch nicht grade sehr sicher.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291675</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291675</guid><dc:creator><![CDATA[Kenner der Scene]]></dc:creator><pubDate>Thu, 24 May 2007 18:49:15 GMT</pubDate></item><item><title><![CDATA[Reply to Aus std::string einen std::wstring machen on Thu, 24 May 2007 18:58:30 GMT]]></title><description><![CDATA[<p>Kenner der Scene schrieb:</p>
<blockquote>
<p>@virtuell Realisticer<br />
keine sehr schöne lösung, sie geht zwar, ist jedoch unflexibel und auch nicht grade sehr sicher.</p>
</blockquote>
<p>bitte mal erklären</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291692</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291692</guid><dc:creator><![CDATA[Nichtkenner]]></dc:creator><pubDate>Thu, 24 May 2007 18:58:30 GMT</pubDate></item><item><title><![CDATA[Reply to Aus std::string einen std::wstring machen on Fri, 25 May 2007 08:30:01 GMT]]></title><description><![CDATA[<p>Nichtkenner schrieb:</p>
<blockquote>
<p>Kenner der Scene schrieb:</p>
<blockquote>
<p>@virtuell Realisticer<br />
keine sehr schöne lösung, sie geht zwar, ist jedoch unflexibel und auch nicht grade sehr sicher.</p>
</blockquote>
<p>bitte mal erklären</p>
</blockquote>
<p>Er hat schon recht, wenn z. B. ein anderer Zeichensatz zu grunde liegt, welcher<br />
nicht mit dem Wertebereich von 0 - 127 auskommt, wie ASCII, wird man damit wenig<br />
erfolg haben.</p>
<p>Alternativ:</p>
<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39492.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-39492.html</a></p>
<p>Hab ich auch gerade erst gesehn.</p>
<p>gruss<br />
v R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1292005</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1292005</guid><dc:creator><![CDATA[virtuell Realisticer]]></dc:creator><pubDate>Fri, 25 May 2007 08:30:01 GMT</pubDate></item></channel></rss>