<?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[unsigned char in TString umwandeln]]></title><description><![CDATA[<p>Hi</p>
<p>Ich habe einen <strong>unsigned char</strong></p>
<pre><code class="language-cpp">unsigned char InString[COM_BUFFER_SIZE + 1]
</code></pre>
<p>und möchte ihn in ein <strong>String</strong> umwandeln, um ihn mit einem <strong>TLabel</strong> anzeigen zu können.</p>
<p>Wer kann mir helfen?, bin unter Zeitdruck, Schulprojekt!<br />
<strong>Danke schon mal!</strong></p>
<p>gruß FB4</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/94177/unsigned-char-in-tstring-umwandeln</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Jul 2026 22:03:13 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/94177.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 06 Dec 2004 18:07:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to unsigned char in TString umwandeln on Mon, 06 Dec 2004 18:07:47 GMT]]></title><description><![CDATA[<p>Hi</p>
<p>Ich habe einen <strong>unsigned char</strong></p>
<pre><code class="language-cpp">unsigned char InString[COM_BUFFER_SIZE + 1]
</code></pre>
<p>und möchte ihn in ein <strong>String</strong> umwandeln, um ihn mit einem <strong>TLabel</strong> anzeigen zu können.</p>
<p>Wer kann mir helfen?, bin unter Zeitdruck, Schulprojekt!<br />
<strong>Danke schon mal!</strong></p>
<p>gruß FB4</p>
]]></description><link>https://www.c-plusplus.net/forum/post/667448</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/667448</guid><dc:creator><![CDATA[FB4]]></dc:creator><pubDate>Mon, 06 Dec 2004 18:07:47 GMT</pubDate></item><item><title><![CDATA[Reply to unsigned char in TString umwandeln on Mon, 06 Dec 2004 18:41:17 GMT]]></title><description><![CDATA[<p>StrCopy(char * Dest, const char * Source);</p>
]]></description><link>https://www.c-plusplus.net/forum/post/667486</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/667486</guid><dc:creator><![CDATA[T_B__]]></dc:creator><pubDate>Mon, 06 Dec 2004 18:41:17 GMT</pubDate></item><item><title><![CDATA[Reply to unsigned char in TString umwandeln on Mon, 06 Dec 2004 18:42:43 GMT]]></title><description><![CDATA[<p>Da die Caption von TLabel ein AnsiString ist, würd ich einfach mal die normale Zuweisung ausprobieren. Wenn das nicht hilft, caste das Array einfach nach char. Dann sollte es auf jeden fall klappen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/667489</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/667489</guid><dc:creator><![CDATA[PuppetMaster2k]]></dc:creator><pubDate>Mon, 06 Dec 2004 18:42:43 GMT</pubDate></item><item><title><![CDATA[Reply to unsigned char in TString umwandeln on Mon, 06 Dec 2004 19:04:00 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/7517">@T_B__</a> StrCopy: geht nicht! TString bleibt unverändert!</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/1592">@PuppetMaster2k</a>:<br />
Normale Zuweisung? So oder? Label1-&gt;Caption=InString;<br />
das geht nicht!<br />
was meinst du mit Array nach char casten?</p>
<p>gruß FB4</p>
]]></description><link>https://www.c-plusplus.net/forum/post/667511</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/667511</guid><dc:creator><![CDATA[FB4]]></dc:creator><pubDate>Mon, 06 Dec 2004 19:04:00 GMT</pubDate></item><item><title><![CDATA[Reply to unsigned char in TString umwandeln on Mon, 06 Dec 2004 20:19:19 GMT]]></title><description><![CDATA[<p>Bei mir funktioniert es mit StrCopy, wenn der String schon genügend Zeichen hat.</p>
<pre><code class="language-cpp">unsigned char InString[10];
InString[0] = 'a';
InString[1] = 'b';
InString[2] = 'c';
InString[3] = 0;
String s = &quot;              &quot;;
StrCopy(s.c_str(),InString);
Label1-&gt;Caption = s;             //Caption -&gt; &quot;abc&quot;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/667559</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/667559</guid><dc:creator><![CDATA[T_B__]]></dc:creator><pubDate>Mon, 06 Dec 2004 20:19:19 GMT</pubDate></item><item><title><![CDATA[Reply to unsigned char in TString umwandeln on Mon, 06 Dec 2004 23:14:27 GMT]]></title><description><![CDATA[<p>FB4 schrieb:</p>
<blockquote>
<p>TString bleibt unverändert!</p>
</blockquote>
<p>Kurze Anmerkung: TString ist eine abstrakte Klasse und kann daher nicht instanziert werden!</p>
<p>FB4 schrieb:</p>
<blockquote>
<p>was meinst du mit Array nach char casten?</p>
</blockquote>
<p>Damit meine ich sowas:</p>
<pre><code class="language-cpp">unsigned char InString[] = &quot;Ich werde mal eine Caption&quot;;
//C++ Style Cast
Lable1-&gt;Caption = static_cast&lt;char&gt;(InString);
//oder C-Style Cast
Lable1-&gt;Caption = (char)InString;
</code></pre>
<p>Aber warum muss es denn ein unsigned char Array sein? Hat das einen speziellen Grund? Warum nicht AnsiString oder std::string?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/667682</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/667682</guid><dc:creator><![CDATA[PuppetMaster2k]]></dc:creator><pubDate>Mon, 06 Dec 2004 23:14:27 GMT</pubDate></item><item><title><![CDATA[Reply to unsigned char in TString umwandeln on Tue, 07 Dec 2004 08:18:52 GMT]]></title><description><![CDATA[<p>sollte es nicht auch mit folgendem gehen?</p>
<pre><code class="language-cpp">unsigned char InString[] = &quot;Ich werde mal eine Caption&quot;;
AnsiString    Str        = AnsiString((char*) InString);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/667765</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/667765</guid><dc:creator><![CDATA[Sunday]]></dc:creator><pubDate>Tue, 07 Dec 2004 08:18:52 GMT</pubDate></item><item><title><![CDATA[Reply to unsigned char in TString umwandeln on Tue, 07 Dec 2004 08:48:27 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/1592">@PuppetMaster2k</a><br />
Wenn schon casten, dann so<br />
Lable1-&gt;Caption = reinterpret_cast&lt;char *&gt;(InString);<br />
Immerhin ist InString ein char-Array</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/588">@Sunday</a><br />
Die explizite Umwandlung des gecasteten InString ist hier nicht nötig (siehe oben).</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/7517">@T_B__</a><br />
Dein StrCopy auf den internen AnsiString-Pointer ist gefählich. Du weisst schließlich nicht, wieviel Speicher da vereinbart wurde und kannst damit also auch in nichtallozierten Speicher schreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/667788</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/667788</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 07 Dec 2004 08:48:27 GMT</pubDate></item><item><title><![CDATA[Reply to unsigned char in TString umwandeln on Tue, 07 Dec 2004 17:05:55 GMT]]></title><description><![CDATA[<p>**@all Danke es hat geklappt</p>
<p>Habe aber ein neues Problem:**</p>
<p>Ich programmiere ein Programm welches über die Com-Schnittstelle Daten von einer Wetterstation (von ELV - <a href="http://www.elv.de" rel="nofollow">www.elv.de</a>) empfängt.</p>
<p>Gesendet wird mit: 19200 Baud, 8 Bit, ungerade Parität und 2 Stopp-Bit<br />
Hier ist das Datenprotokoll: <a href="http://www.elv-downloads.de/service/manuals/PC-WS-Testempfaenger/39061-PC-WS-Testempfaenger.pdf" rel="nofollow">http://www.elv-downloads.de/service/manuals/PC-WS-Testempfaenger/39061-PC-WS-Testempfaenger.pdf</a></p>
<p><strong>Also habe ich erstmal den Port geöffnet ....</strong></p>
<pre><code class="language-cpp">DCB dcb;
hCom = CreateFile (&quot;Com1&quot;,GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
dcb.DCBlength = sizeof (DCB);
GetCommState (hCom,&amp;dcb);
dcb.BaudRate=9600;
dcb.ByteSize=8;
dcb.Parity=NOPARITY;
dcb.StopBits=ONESTOPBIT;
SetCommState (hCom, &amp;dcb);

if (hCom == INVALID_HANDLE_VALUE) // hat es geklappt? Bei Fehler ist hier Schluss!
   {
      MessageBox (NULL, &quot;Fehler beim Öffnen des COM-Ports&quot;, NULL, NULL);

   }
}
</code></pre>
<p>.... dann die Read funkion ausgeführt ....</p>
<pre><code class="language-cpp">unsigned char InString[COM_BUFFER_SIZE + 1];

DWORD dwRead = 0;
if(!ReadFile (hCom,&amp;InString,sizeof (InString),&amp;dwRead,NULL))Application-&gt;MessageBox(&quot;Fehler!!!!&quot;,&quot;&quot;,0);

if(dwRead != 0)
{
InString[dwRead]='\0';
}

Label1-&gt;Caption = reinterpret_cast&lt;char *&gt;(InString);
</code></pre>
<p><strong>Nun zum Problem:</strong><br />
Die Wetterstation schickt alle 3min neue Daten.<br />
Aber schon nach 10 sek bekomme ich eine Antwort von der COM.<br />
Und zwar sehr merkwürdige zeichen, zB <strong>˜ï</strong></p>
<p>Brauche dringend Hilfe! Danke!</p>
<p>gruß FB4 <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/668248</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/668248</guid><dc:creator><![CDATA[FB4]]></dc:creator><pubDate>Tue, 07 Dec 2004 17:05:55 GMT</pubDate></item></channel></rss>