<?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[string in wstring konvertieren?]]></title><description><![CDATA[<p>Gibt es eine Möglichkeit einfach einen char string in einen wide char string zu konvertieren? Stehe leider das erste mal vor diesem Problem.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/133034/string-in-wstring-konvertieren</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 04:01:26 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/133034.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 14 Jan 2006 21:05:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to string in wstring konvertieren? on Sat, 14 Jan 2006 21:05:21 GMT]]></title><description><![CDATA[<p>Gibt es eine Möglichkeit einfach einen char string in einen wide char string zu konvertieren? Stehe leider das erste mal vor diesem Problem.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/966753</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/966753</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Sat, 14 Jan 2006 21:05:21 GMT</pubDate></item><item><title><![CDATA[Reply to string in wstring konvertieren? on Sun, 15 Jan 2006 01:04:06 GMT]]></title><description><![CDATA[<p>So, nach einer Suche im Internet hab ich folgendes gefunden:</p>
<pre><code class="language-cpp">#include &lt;string&gt;
#include &lt;vector&gt;
#include &lt;locale&gt;
#include &lt;functional&gt;
#include &lt;iostream&gt;

// Put this class in your personal toolbox...
template&lt;class E,
class T = std::char_traits&lt;E&gt;,
class A = std::allocator&lt;E&gt; &gt;

class Widen : public std::unary_function&lt;
const std::string&amp;, std::basic_string&lt;E, T, A&gt; &gt;
{
std::locale loc_;
const std::ctype&lt;E&gt;* pCType_;

// No copy-constructor, no assignment operator...
Widen(const Widen&amp;);
Widen&amp; operator= (const Widen&amp;);

public:
// Constructor...
Widen(const std::locale&amp; loc = std::locale()) : loc_(loc)
{
#if defined(_MSC_VER) &amp;&amp; (_MSC_VER &lt; 1300) // VC++ 6.0...
using namespace std;
pCType_ = &amp;_USE(loc, ctype&lt;E&gt; );
#else
pCType_ = &amp;std::use_facet&lt;std::ctype&lt;E&gt; &gt;(loc);
#endif
}

// Conversion...
std::basic_string&lt;E, T, A&gt; operator() (const std::string&amp; str) const
{
typename std::basic_string&lt;E, T, A&gt;::size_type srcLen =
str.length();
const char* pSrcBeg = str.c_str();
std::vector&lt;E&gt; tmp(srcLen);

pCType_-&gt;widen(pSrcBeg, pSrcBeg + srcLen, &amp;tmp[0]);
return std::basic_string&lt;E, T, A&gt;(&amp;tmp[0], srcLen);
}
};

// How to use it...
int main()
{
Widen&lt;wchar_t&gt; to_wstring;
std::string s = &quot;my test string&quot;;
std::wstring w = to_wstring(s);
std::wcout &lt;&lt; w &lt;&lt; L&quot;\n&quot;;
}
</code></pre>
<p>Falls jemand eine Lösung aus der Standardlib oder Boost hat, würde ich mich auch freuen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/966832</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/966832</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Sun, 15 Jan 2006 01:04:06 GMT</pubDate></item><item><title><![CDATA[Reply to string in wstring konvertieren? on Sun, 15 Jan 2006 01:26:30 GMT]]></title><description><![CDATA[<p>Für Windowsuser:<br />
<a href="http://www.spieleprogrammierer.de/phpBB2/viewtopic.php?t=4701" rel="nofollow">http://www.spieleprogrammierer.de/phpBB2/viewtopic.php?t=4701</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/966835</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/966835</guid><dc:creator><![CDATA[this-&amp;gt;g]]></dc:creator><pubDate>Sun, 15 Jan 2006 01:26:30 GMT</pubDate></item><item><title><![CDATA[Reply to string in wstring konvertieren? on Wed, 15 Mar 2006 12:26:04 GMT]]></title><description><![CDATA[<p>also bei mir funktioniert dies leider nicht so wie ich möchte <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>ich hab in einen normalen std::string folgenden inhalt drinnen: &quot;Magia wrÂoÇzb&quot;</p>
<p>der inhalt müsste ist eigentlich im ISO/IEC 6937 standard sein. jetzt hab ich mir gedacht, vielleicht kann ich dies automatisch konvertieren mittels wstring, leider bricht die konvertierung ab.</p>
<p>das ergebnis sollte &quot;Magia wróżb&quot; sein und ist polnisch.<br />
wenn man nach wstring und iso 6937 sucht erhält man komischerweise ergebnisse, dass der wstring dies kann, aber leider findet man keine konvertierung die ich verwenden könnte bzw. hinweise.</p>
<p>hat jemand eine idee???<br />
danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1016640</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1016640</guid><dc:creator><![CDATA[iso6937]]></dc:creator><pubDate>Wed, 15 Mar 2006 12:26:04 GMT</pubDate></item></channel></rss>