<?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[wchar_t Größe]]></title><description><![CDATA[<p>Hallo ,</p>
<p>bin etwa verwirrt was die Größe von wchar_t angeht.</p>
<p>Sind es 16 Bit oder 32 Bit ?</p>
<p>Danke.</p>
<p>mfg, Elke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/172565/wchar_t-größe</link><generator>RSS for Node</generator><lastBuildDate>Fri, 18 Sep 2026 01:41:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/172565.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 06 Feb 2007 11:48:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to wchar_t Größe on Tue, 06 Feb 2007 11:48:14 GMT]]></title><description><![CDATA[<p>Hallo ,</p>
<p>bin etwa verwirrt was die Größe von wchar_t angeht.</p>
<p>Sind es 16 Bit oder 32 Bit ?</p>
<p>Danke.</p>
<p>mfg, Elke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1223749</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1223749</guid><dc:creator><![CDATA[Elke_100]]></dc:creator><pubDate>Tue, 06 Feb 2007 11:48:14 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t Größe on Tue, 06 Feb 2007 11:52:07 GMT]]></title><description><![CDATA[<p>Das ist afaik vom Standard nicht vorgeschrieben (bzw. &quot;implementation-defined&quot;) - d.h. beides ist im Zweifelsfall möglich.</p>
<p>(wie es auf deinem System aussieht, kannst du ja per sizeof() nachmessen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1223752</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1223752</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 06 Feb 2007 11:52:07 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t Größe on Tue, 06 Feb 2007 11:53:27 GMT]]></title><description><![CDATA[<p>Mindes so groß wie ein char und maximal so groß wie ein long. Außerdem gibts kein explizites unsigned wchar_t. Der Typ is immer dann unsigned wenn der unterliegened Intergertyp (den wchar_t benötigt) unsigned ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1223753</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1223753</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Tue, 06 Feb 2007 11:53:27 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t Größe on Tue, 06 Feb 2007 11:59:13 GMT]]></title><description><![CDATA[<p>Danke !</p>
<p>Kann ich den wchar irgendwie auf 16 Bit festlegen ?</p>
<p>Das Problem ist , ich möchte einen char in wchar_t ( mit Größe 16 Bit ) casten.<br />
Aber ich muss sicher gehen , dass wchar_t -16 Bit groß ist ?</p>
<p>Gibt es da eine Möglichkeit so etwas zu machen ?</p>
<p>danke.</p>
<p>mfg , Elke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1223764</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1223764</guid><dc:creator><![CDATA[Elke_100]]></dc:creator><pubDate>Tue, 06 Feb 2007 11:59:13 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t Größe on Tue, 06 Feb 2007 12:01:22 GMT]]></title><description><![CDATA[<p>Nein, es sei denn du suchst dir einen Typen raus der definitiv 16 Bit breit ist und verwendest den.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1223766</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1223766</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Tue, 06 Feb 2007 12:01:22 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t Größe on Tue, 06 Feb 2007 12:05:40 GMT]]></title><description><![CDATA[<p>Technisch: Nein (was sich hinter &quot;wchar_t&quot; verbirgt, entscheidet dein Compiler - eventuell bietet er die Möglichkeit, an den Größenvorgaben zu schrauben).</p>
<p>Praktisch: Muß es denn unbedingt wchar_t sein? Du könntest zur Not einen eigenen Typ <code>my_wchar</code> definieren (z.B. als 'unsigned short') - da kannst du genau einstellen, wie groß er werden soll.<br />
(irgendwo habe ich mal eine Template-Konstruktion gesehen, mit der man gezielt einen n-Byte-Integertyp auswählen konnte)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1223770</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1223770</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 06 Feb 2007 12:05:40 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t Größe on Tue, 06 Feb 2007 12:17:35 GMT]]></title><description><![CDATA[<p>Was meint ihr , wenn ich das so mache :</p>
<pre><code class="language-cpp">int nWChar_Laenge = sizeof( wchar_t );
     #if ( nWChar_Laenge == 2 )
	typedef wchar_t UChar;
     #else
	typedef unsigned short UChar;
     #endif
</code></pre>
<p>Dann ist ja der UChar immer 16 Bit groß.</p>
<p>mfg , Elke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1223777</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1223777</guid><dc:creator><![CDATA[Elke_100]]></dc:creator><pubDate>Tue, 06 Feb 2007 12:17:35 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t Größe on Tue, 06 Feb 2007 12:19:21 GMT]]></title><description><![CDATA[<p>Jep, hab ich auchmal was gebastelt. Dafür verwendete ich Typenlisten (die Implementation aus 'Modern C++ Design'):</p>
<p>Gekürzt:</p>
<pre><code class="language-cpp">struct NullType {};

template&lt; bool b, typename T, typename U &gt;
struct Select
{
	typedef T Result;
};

template&lt; typename T, typename U &gt;
struct Select&lt; false, T, U &gt;
{
	typedef U Result;
};

template&lt; typename T, typename U &gt;
struct TypeList
{
	typedef T Head;
	typedef U Tail;
};

namespace TL
{
	template&lt; typename TList, unsigned int bits &gt; 
	struct TypeBySize; 

	template&lt; unsigned int bits &gt; 
	struct TypeBySize&lt; NullType, bits &gt; 
	{ 
		typedef void Type; 
	}; 

	template&lt; typename T, typename U, unsigned int bits &gt; 
	struct TypeBySize&lt; TypeList&lt; T, U &gt;, bits &gt; 
	{ 
		typedef typename Select&lt; ( ( sizeof( T ) * CHAR_BIT ) == bits ), T, typename TypeBySize&lt; U, bits &gt;::Type &gt;::Result Type; 
	}; 
};

#define TYPELIST_1( T1 ) TypeList&lt; T1, NullType &gt;
#define TYPELIST_2( T1, T2 ) TypeList&lt; T1, TYPELIST_1( T2 ) &gt;
#define TYPELIST_3( T1, T2, T3 ) TypeList&lt; T1, TYPELIST_2( T2, T3 ) &gt;
#define TYPELIST_4( T1, T2, T3, T4 ) TypeList&lt; T1, TYPELIST_3( T2, T3, T4 ) &gt;
#define TYPELIST_5( T1, T2, T3, T4, T5 ) TypeList&lt; T1, TYPELIST_4( T2, T3, T4, T5 ) &gt;
</code></pre>
<p>Hab nur meine eigene Funktionalität im Namespace TL mit aufgelistet. Der Rest wäre hier irrelevant.</p>
<p>Und verwendet wird das so:</p>
<pre><code class="language-cpp">typedef TYPELIST_4( signed char, signed short, signed int, signed long ) SIntegralTypes;

int main( int argc, char* argv[] )
{
	typedef TL::TypeBySize&lt; SIntegralTypes, 16 &gt;::Type My16BitWChar;

	My16BitWChar foobar = 0x7fff;
	std::cout &lt;&lt; sizeof( foobar ) &lt;&lt; std::endl;
}
</code></pre>
<p>grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1223781</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1223781</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Tue, 06 Feb 2007 12:19:21 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t Größe on Tue, 06 Feb 2007 12:49:28 GMT]]></title><description><![CDATA[<p>Hallo David ,</p>
<p>interessante Lösung !</p>
<p>danke.</p>
<p>mfg, Olga</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1223794</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1223794</guid><dc:creator><![CDATA[Elke_100]]></dc:creator><pubDate>Tue, 06 Feb 2007 12:49:28 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t Größe on Tue, 06 Feb 2007 13:12:41 GMT]]></title><description><![CDATA[<p>Eventuell ist dazu auch noch folgender FAQ-Beitrag interessant:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-131658.html" rel="nofollow">Absolute Typgrößen mit templates</a></p>
<p>Greetz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1223822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1223822</guid><dc:creator><![CDATA[Vellas]]></dc:creator><pubDate>Tue, 06 Feb 2007 13:12:41 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t Größe on Tue, 06 Feb 2007 22:13:03 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;boost/cstdint.hpp&gt;
typedef boost::uint16_t my_wchar_t;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1224144</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1224144</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 06 Feb 2007 22:13:03 GMT</pubDate></item></channel></rss>