<?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übergabe von JAVA nach C++]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe folgendes Problem :<br />
ich habe eine C++ DLL, die von einem JAVA-Programm<br />
benutzt wird ( J++ ), ein Text in Java ist String, in C++ Char*,<br />
bei der Übergabe in eine Funktion habe ich in dem Text nach jedem<br />
Zeichen ein &quot;\n&quot;, also es wird z.B. &quot;12345&quot; übergeben und<br />
es kommt &quot;1\n2\n3\n4\n5\n&quot; an.</p>
<p>Kennt jemand das Problem ?<br />
Was mache ich falsch ?</p>
<p>Danke<br />
Gruss<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/81298/stringübergabe-von-java-nach-c</link><generator>RSS for Node</generator><lastBuildDate>Fri, 21 Aug 2026 15:14:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/81298.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 30 Jul 2004 06:37:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 06:37:35 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe folgendes Problem :<br />
ich habe eine C++ DLL, die von einem JAVA-Programm<br />
benutzt wird ( J++ ), ein Text in Java ist String, in C++ Char*,<br />
bei der Übergabe in eine Funktion habe ich in dem Text nach jedem<br />
Zeichen ein &quot;\n&quot;, also es wird z.B. &quot;12345&quot; übergeben und<br />
es kommt &quot;1\n2\n3\n4\n5\n&quot; an.</p>
<p>Kennt jemand das Problem ?<br />
Was mache ich falsch ?</p>
<p>Danke<br />
Gruss<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/571335</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571335</guid><dc:creator><![CDATA[AlexSnd]]></dc:creator><pubDate>Fri, 30 Jul 2004 06:37:35 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 06:41:24 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>hab ich selber noch nie gemacht,<br />
aber probiers doch auch unter C++ mal mit string.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/571338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571338</guid><dc:creator><![CDATA[nichteingeloggter]]></dc:creator><pubDate>Fri, 30 Jul 2004 06:41:24 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 06:46:09 GMT]]></title><description><![CDATA[<p>Wie geht das ?<br />
C++ &quot;kennt&quot; doch normal keine Strings...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/571340</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571340</guid><dc:creator><![CDATA[AlexSnd]]></dc:creator><pubDate>Fri, 30 Jul 2004 06:46:09 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 07:18:51 GMT]]></title><description><![CDATA[<p>C++ kennt std::string. Eine Klasse die das Äquvivalent zu String in Java darstellt <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>
]]></description><link>https://www.c-plusplus.net/forum/post/571354</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571354</guid><dc:creator><![CDATA[PuppetMaster2k]]></dc:creator><pubDate>Fri, 30 Jul 2004 07:18:51 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 07:26:11 GMT]]></title><description><![CDATA[<p>Genau,<br />
guckst du hier:<br />
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcstdlib/html/vclrf_string_string.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcstdlib/html/vclrf_string_string.asp</a><br />
Da gibt's auch'n Beispiel</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/571357</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571357</guid><dc:creator><![CDATA[nichteingeloggter]]></dc:creator><pubDate>Fri, 30 Jul 2004 07:26:11 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 07:34:51 GMT]]></title><description><![CDATA[<p>Mit dem std::string kriege ich &quot;unknownError&quot; auf der Java Seite,<br />
scheint also nicht so richtig kompaibel zu sein <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>
]]></description><link>https://www.c-plusplus.net/forum/post/571360</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571360</guid><dc:creator><![CDATA[AlexSnd]]></dc:creator><pubDate>Fri, 30 Jul 2004 07:34:51 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 08:22:07 GMT]]></title><description><![CDATA[<p>Hm,<br />
keine Ahnung hab sowas auch noch nie gemacht.<br />
Poste doch mal die relevanten Codestellen.<br />
Kannst ja in Java die ganzen \n entfernen (String mit .toCharArray() wandeln, und in ner schleife nur die gewünschen rauslesen). Kostet aber weng Performance.</p>
<p>Gruß<br />
Threaddy</p>
]]></description><link>https://www.c-plusplus.net/forum/post/571400</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571400</guid><dc:creator><![CDATA[Threaddy]]></dc:creator><pubDate>Fri, 30 Jul 2004 08:22:07 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 09:28:17 GMT]]></title><description><![CDATA[<p>Wenn ich den Text von java &quot;wegschicke&quot;, sind ja noch keine &quot;\n&quot; drin,<br />
wenn dann müsste ich sie in C entfernen ( was natürlich keine gute Lösung wäre ).</p>
<p>hier der Code :<br />
java :</p>
<pre><code>public static void main(String args[])
{
  userdll UserAPI = new userdll();
  s_text = &quot;1234567890&quot;;
  :
  String s_text;
  :
  i_ergebnis = UserAPI.USEDLL_test ( s_text, 25, 5 );
  :
</code></pre>
<p>C</p>
<pre><code>long __stdcall USEDLL_test ( char* text, long a,long b)
{
  :
  MessageBox(  0, text, MB_OK, MB_ICONINFORMATION );  // es wird nur die 1 ausgegeben
  :
  return(a+b);

}
</code></pre>
<pre><code>long __stdcall USEDLL_test ( char* text, long a,long b)
{
  :
  for(n=1;n&lt;21;n++)
  {	
     MessageBox(  0, text, MB_OK, MB_ICONINFORMATION );  // es wird 1\n2\n usw. ausgegeben
     ++text;
  }
  :
  return(a+b);

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/571419</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571419</guid><dc:creator><![CDATA[AlexSnd]]></dc:creator><pubDate>Fri, 30 Jul 2004 09:28:17 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 09:17:58 GMT]]></title><description><![CDATA[<p>Hi,<br />
also ich blick jetzt da net so ganz durch (gut hab auch noch nicht viel Oberflächenprogrammierung gemacht), aber sind bei der Messagebox nicht die ersten beiden Parameter die Strings die ausgegeben werden sollen (Also Text und Titelzeile)?<br />
Du gibst doch da die Variabel xml aus (da du die hochzählst denk ich daß die kein String oder Char ist).</p>
<p><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cwnd.3a3a.messagebox.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cwnd.3a3a.messagebox.asp</a></p>
<p>Kann sein daß ich da jetzt komlett falsch liege (dann sorry dafür). Was andres fällt mir jetzt dazu aber nicht ein.</p>
<p>Gruß<br />
Threaddy</p>
]]></description><link>https://www.c-plusplus.net/forum/post/571451</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571451</guid><dc:creator><![CDATA[Threaddy]]></dc:creator><pubDate>Fri, 30 Jul 2004 09:17:58 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 09:34:09 GMT]]></title><description><![CDATA[<p>Sorry, habe da was falsches geschrieben ( *rotwerd* )<br />
Es ist jetzt korrigiert.</p>
<p>Parameter der MessageBox :<br />
MessageBox ( int hWind, String lpText, String lpCaption, int uType );</p>
<p>Ich zähle eigentlich die Var. text hoch, es ist ein Pointer auf Char.<br />
Das habe ich aber nur gemacht, um zu sehen, wo das Problem liegt.<br />
Ich habe halt über das \n weitergelesen und sieh da : da war auch der restliche Tetx drin <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>
]]></description><link>https://www.c-plusplus.net/forum/post/571465</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571465</guid><dc:creator><![CDATA[AlexSnd]]></dc:creator><pubDate>Fri, 30 Jul 2004 09:34:09 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 09:54:43 GMT]]></title><description><![CDATA[<p>Hi,<br />
hast du mal probiert des mit cout einfach auf der Konsole auszugeben?<br />
Nur um Fehler bei der Messagebox auszuschließen.<br />
Bist du sicher daß das \n und net \0 (C++ String-Ende-Zeichen) ist.</p>
<p>Gruß Threaddy</p>
]]></description><link>https://www.c-plusplus.net/forum/post/571490</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571490</guid><dc:creator><![CDATA[Threaddy]]></dc:creator><pubDate>Fri, 30 Jul 2004 09:54:43 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 10:15:46 GMT]]></title><description><![CDATA[<p>Threaddy schrieb:</p>
<blockquote>
<p>Hi,<br />
hast du mal probiert des mit cout einfach auf der Konsole auszugeben?<br />
Nur um Fehler bei der Messagebox auszuschließen.</p>
</blockquote>
<p>Einen Fehler bei der MessageBox kann ich ausschliessen, denn<br />
das geht :</p>
<pre><code>char* text = &quot;12345&quot;;
MessageBox ( (  0, text, MB_OK, MB_ICONINFORMATION );
</code></pre>
<p>Threaddy schrieb:</p>
<blockquote>
<p>Bist du sicher daß das \n und net \0 (C++ String-Ende-Zeichen) ist.</p>
</blockquote>
<p>Irgendiwie bin ich heute nicht gut drauf, ich meinte natürlich (C++ String-Ende-Zeichen), also \0 <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Gruss<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/571514</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571514</guid><dc:creator><![CDATA[AlexSnd]]></dc:creator><pubDate>Fri, 30 Jul 2004 10:15:46 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 10:26:48 GMT]]></title><description><![CDATA[<p>Hi AlexSnd,</p>
<p>Java schickt Unicode (16-Bit) ab und du empfängst char (8-Bit).<br />
Daran liegt das. Denk dir was aus!</p>
<p>Jockelx</p>
]]></description><link>https://www.c-plusplus.net/forum/post/571532</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571532</guid><dc:creator><![CDATA[Jockelx]]></dc:creator><pubDate>Fri, 30 Jul 2004 10:26:48 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 10:49:21 GMT]]></title><description><![CDATA[<p>Hm,<br />
stimmt. Des wird's wohl sein.<br />
Würde dann in java einfach n char[] draus machen.</p>
<p>Gruß<br />
Threaddy</p>
]]></description><link>https://www.c-plusplus.net/forum/post/571554</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571554</guid><dc:creator><![CDATA[Threaddy]]></dc:creator><pubDate>Fri, 30 Jul 2004 10:49:21 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 11:18:09 GMT]]></title><description><![CDATA[<p>Threaddy schrieb:</p>
<blockquote>
<p>Würde dann in java einfach n char[] draus machen.</p>
</blockquote>
<p>Oder man benutzt einfach</p>
<pre><code>#define UNICODE
</code></pre>
<p>Danke für Eure Geduld <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/571572</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571572</guid><dc:creator><![CDATA[AlexSnd]]></dc:creator><pubDate>Fri, 30 Jul 2004 11:18:09 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 11:24:34 GMT]]></title><description><![CDATA[<p>AlexSnd schrieb:</p>
<blockquote>
<p>Oder man benutzt einfach</p>
<pre><code>#define UNICODE
</code></pre>
</blockquote>
<p>Des kannt ich jetzt noch nicht. Wieder was gelernt <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="🙂"
    /><br />
Geh mal davon aus daß es jetzt funzt.</p>
<p>Gruß Threaddy</p>
]]></description><link>https://www.c-plusplus.net/forum/post/571575</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571575</guid><dc:creator><![CDATA[Threaddy]]></dc:creator><pubDate>Fri, 30 Jul 2004 11:24:34 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Fri, 30 Jul 2004 11:29:44 GMT]]></title><description><![CDATA[<p>Threaddy schrieb:</p>
<blockquote>
<p>Geh mal davon aus daß es jetzt funzt.</p>
</blockquote>
<p>Ja es funzt, Unicode muss eingeschaltet sein und der Text als LPCTSTR declariert werden.</p>
<p>Gruss<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/571578</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571578</guid><dc:creator><![CDATA[AlexSnd]]></dc:creator><pubDate>Fri, 30 Jul 2004 11:29:44 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Wed, 24 Aug 2005 08:12:10 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>habe hier mal meinen alten Thread ausgegraben, weil ich wieder ein ähnliches Problem habe.</p>
<p>Diesmal geht es aber um die Rückgabe eines String von C++ nach Java.<br />
Wie funktioniert das ? Ich habe schon viele Möglichkeiten probiert, aber bestenfalls kommt Mühl an, meisten schmiert das Programm ab <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>Danke<br />
Gruss<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/857326</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/857326</guid><dc:creator><![CDATA[AlexSnd]]></dc:creator><pubDate>Wed, 24 Aug 2005 08:12:10 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Wed, 24 Aug 2005 08:15:45 GMT]]></title><description><![CDATA[<p>PuppetMaster2k schrieb:</p>
<blockquote>
<p>C++ kennt std::string. Eine Klasse die das Äquvivalent zu String in Java darstellt <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>
</blockquote>
<p>Wenn schon std::wstring. Java Strings sind Unicode, und std::string ist es nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/857328</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/857328</guid><dc:creator><![CDATA[phlox81]]></dc:creator><pubDate>Wed, 24 Aug 2005 08:15:45 GMT</pubDate></item><item><title><![CDATA[Reply to Stringübergabe von JAVA nach C++ on Wed, 24 Aug 2005 11:38:13 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6770">@AlexSnd</a>:</p>
<p>Du musst das Ding irgendwie als byte[] in dein Java-Programm kriegen. Daraus kannst du dann den java.lang.String konstruieren, wenn du die Zeichenkodierung kennst.<br />
Wovon genau die Zeichenkodierung des std::strings abhängt, versuch ich noch rauszufinden. Wenn ich meinen Quelltext als UTF-8 abspeichere, hat der std::string für ein Ü zwei Zeichen. Also hängt es vielleicht von der Kodierung des Quelltexts ab und der C++-Compiler übernimmt einfach die Bytes, die so kommen. Wahrscheinlich ist UTF-8 dann die beste Wahl, ohne BOM müsste das auch ein dummer C++-Compiler bearbeiten können.</p>
<p>Wenn du nen wstring hast, ist sowieso gar nichts mehr sicher, ne plattformunabhängige Lösung kriegst du dann nicht her. Beim VC++ wäre es ein UTF-16 String. Die Vorgehensweise in Java wäre die selbe, byte[] daraus machen und mit UTF-16 String erstellen. Ich würde nicht empfehlen, die 16-Bit chars direkt in Java unverändert zu übernehmen, weil Java die binäre 0 speziell kodiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/857470</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/857470</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 24 Aug 2005 11:38:13 GMT</pubDate></item></channel></rss>