<?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[basic_string&amp;lt;char&amp;gt; in basic_string&amp;lt;wchar_t&amp;gt; konvertieren]]></title><description><![CDATA[<p>Wie konvertiere ich in iso-c++ einen char-string in einen wchar_t-string? Das müsste doch irgendwie über die Locales gehen, oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/150324/basic_string-lt-char-gt-in-basic_string-lt-wchar_t-gt-konvertieren</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 14:32:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/150324.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 15 Jun 2006 11:25:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to basic_string&amp;lt;char&amp;gt; in basic_string&amp;lt;wchar_t&amp;gt; konvertieren on Thu, 15 Jun 2006 11:25:40 GMT]]></title><description><![CDATA[<p>Wie konvertiere ich in iso-c++ einen char-string in einen wchar_t-string? Das müsste doch irgendwie über die Locales gehen, oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1078101</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1078101</guid><dc:creator><![CDATA[Holger R.]]></dc:creator><pubDate>Thu, 15 Jun 2006 11:25:40 GMT</pubDate></item><item><title><![CDATA[Reply to basic_string&amp;lt;char&amp;gt; in basic_string&amp;lt;wchar_t&amp;gt; konvertieren on Thu, 15 Jun 2006 11:59:53 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Schau mal hier rein<br />
<a href="http://www.online-tutorials.net/c++-c/speicherzugriff-tutorial-readprocessmemory-schlaegt-fehl/t-5-168-8-page1.html" rel="nofollow">http://www.online-tutorials.net/c++-c/speicherzugriff-tutorial-readprocessmemory-schlaegt-fehl/t-5-168-8-page1.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1078121</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1078121</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Thu, 15 Jun 2006 11:59:53 GMT</pubDate></item><item><title><![CDATA[Reply to basic_string&amp;lt;char&amp;gt; in basic_string&amp;lt;wchar_t&amp;gt; konvertieren on Thu, 15 Jun 2006 12:28:02 GMT]]></title><description><![CDATA[<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-133034-and-highlight-is-.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-133034-and-highlight-is-.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1078140</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1078140</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Thu, 15 Jun 2006 12:28:02 GMT</pubDate></item><item><title><![CDATA[Reply to basic_string&amp;lt;char&amp;gt; in basic_string&amp;lt;wchar_t&amp;gt; konvertieren on Thu, 15 Jun 2006 13:27:32 GMT]]></title><description><![CDATA[<p>Danke euch beiden. Artchi leider hab ich inzwischen schon meine eigene Version geschrieben.</p>
<p>Braunstein der Link ist zwar nicht schlecht, aber hat mich doch noch etwas an Arbeit gekostet, da ich das so nicht übernehmen konnte. Aber trotzdem danke, habe es ja hinbekommen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Meine Version von widen:</p>
<pre><code class="language-cpp">String ToGString( const char* src, size_t size, const std::locale&amp; loc )
{
#		ifdef UNICODE
	//Unicode -&gt; String is of type wchar_t
	String res( size, 0 );
	mbstate_t state;
	char* pCNext;
	wchar_t* pWNext;

	typedef std::codecvt&lt; wchar_t, char, mbstate_t &gt; codecvt;

	const codecvt&amp; fac = std::use_facet&lt; codecvt &gt;( loc );
	fac.in( state, src, src + size, pCNext, &amp;res[ 0 ], &amp;res[ 0 ] + size, pWNext );

	return res;

#		else
	//No unicode -&gt; String is of type char
	return String( src );
#		endif
}
</code></pre>
<p>Meine Version von narrow:</p>
<pre><code class="language-cpp">String ToGString( const wchar_t* src, size_t size, const std::locale&amp; loc )
{
#		ifdef UNICODE
	//Unicode -&gt; String is of type wchar_t
	return String( src );

#		else
	//No unicode -&gt; String is of type char
	String res( size, 0 );
	mbstate_t state;
	char* pCNext;
	wchar_t* pWNext;

	typedef std::codecvt&lt; wchar_t, char, mbstate_t &gt; codecvt;

	const codecvt&amp; fac = std::use_facet&lt; codecvt &gt;( loc );
	fac.out( state, src, src + size, pWNext, &amp;res[ 0 ], &amp;res[ 0 ] + size, pCNext );

	return res;
#		endif
}
</code></pre>
<p>String ist ein typedef das je nach unicode oder nicht einfach ein std::string oder std::wstring ist. GString heißt es nicht wegen _dem_ G-String, sondern steht für generic string</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1078173</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1078173</guid><dc:creator><![CDATA[Holger R.]]></dc:creator><pubDate>Thu, 15 Jun 2006 13:27:32 GMT</pubDate></item></channel></rss>