<?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[insensitive Compare mit Länge]]></title><description><![CDATA[<p>Ich suche eine C++ Funktion für den insensitive Compare von zwei C++ String, wobei man auch die Länge angeben kann. In C gibt es dafür folgende Funktion:</p>
<p>int _strnicmp(<br />
const char *string1,<br />
const char *string2,<br />
size_t count<br />
);</p>
<p>Wie mache ich das mit der STL?</p>
<p>Gruss und danke,<br />
T.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/278398/insensitive-compare-mit-länge</link><generator>RSS for Node</generator><lastBuildDate>Tue, 25 Aug 2026 07:24:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/278398.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 06 Dec 2010 09:42:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to insensitive Compare mit Länge on Mon, 06 Dec 2010 09:42:57 GMT]]></title><description><![CDATA[<p>Ich suche eine C++ Funktion für den insensitive Compare von zwei C++ String, wobei man auch die Länge angeben kann. In C gibt es dafür folgende Funktion:</p>
<p>int _strnicmp(<br />
const char *string1,<br />
const char *string2,<br />
size_t count<br />
);</p>
<p>Wie mache ich das mit der STL?</p>
<p>Gruss und danke,<br />
T.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990314</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990314</guid><dc:creator><![CDATA[Tomahawk]]></dc:creator><pubDate>Mon, 06 Dec 2010 09:42:57 GMT</pubDate></item><item><title><![CDATA[Reply to insensitive Compare mit Länge on Mon, 06 Dec 2010 09:54:17 GMT]]></title><description><![CDATA[<p>boost::iequals wäre wohl eine Möglichkeit. Für deine Längenangabe könntest du dann vielleicht mit substr arbeiten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990319</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990319</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Mon, 06 Dec 2010 09:54:17 GMT</pubDate></item><item><title><![CDATA[Reply to insensitive Compare mit Länge on Mon, 06 Dec 2010 10:01:47 GMT]]></title><description><![CDATA[<p>Du hast aber exotische Anforderungen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /> . Insensitive Vergleiche sehe ich ja noch die Notwendigkeit, aber mit Längenangabe? Aber ok, schreiben wir uns das doch eben schnell selbst:</p>
<pre><code class="language-cpp">#include&lt;string&gt;
#include&lt;algorithm&gt;
#include&lt;cctype&gt;

// true wenn lhs gleich rhs bis zur Länge length
bool strnicmp(const std::string &amp;lhs, const std::string &amp;rhs, size_t length)
{
  // Wenn length &gt; kürzester String   ---&gt; false
  if (length &gt; std::min(lhs.size(), rhs.size())) return false;

  for(size_t i=0; i&lt;length; ++i)
    {
      if (std::tolower(lhs[i]) != std::tolower(rhs[i])) return false;
    }

  return true;
}
</code></pre>
<p>Entspricht dies ungefähr deinen Anforderungen? Bei der Längenangabe war ich nicht ganz sicher, wie du das genau meinst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990322</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990322</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 06 Dec 2010 10:01:47 GMT</pubDate></item><item><title><![CDATA[Reply to insensitive Compare mit Länge on Mon, 06 Dec 2010 10:04:16 GMT]]></title><description><![CDATA[<p>vergleichsfunktion gibt es ja genügend, auch mit längenangaben:<br />
<a href="http://www.cplusplus.com/reference/string/string/compare/" rel="nofollow">http://www.cplusplus.com/reference/string/string/compare/</a></p>
<p>und für lower/upper einfach<br />
std::tranform nutzen</p>
<pre><code class="language-cpp">std::string Text = &quot;Hallo Welt&quot;;
std::transform(Text.begin(),Text.end(), Text.begin(),tolower);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1990326</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990326</guid><dc:creator><![CDATA[BigNeal]]></dc:creator><pubDate>Mon, 06 Dec 2010 10:04:16 GMT</pubDate></item><item><title><![CDATA[Reply to insensitive Compare mit Länge on Mon, 06 Dec 2010 10:04:16 GMT]]></title><description><![CDATA[<p>Wenn die STL diesen &quot;exotischen&quot; Vergleich nicht vorsieht, dann ist deine Funktion wohl die eleganteste Lösung.</p>
<p>Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990325</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990325</guid><dc:creator><![CDATA[Tomahawk]]></dc:creator><pubDate>Mon, 06 Dec 2010 10:04:16 GMT</pubDate></item><item><title><![CDATA[Reply to insensitive Compare mit Länge on Mon, 06 Dec 2010 10:07:44 GMT]]></title><description><![CDATA[<p>Tomahawk schrieb:</p>
<blockquote>
<p>Wenn die STL diesen &quot;exotischen&quot; Vergleich nicht vorsieht, dann ist deine Funktion wohl die eleganteste Lösung.</p>
</blockquote>
<p>Wobei meine Funktion (bis auf den Range-Check) praktisch 100% dem entsprechen sollte, was strnicmp macht. Du kannst daher auch einfach das alte strnicmp benutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990329</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990329</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 06 Dec 2010 10:07:44 GMT</pubDate></item><item><title><![CDATA[Reply to insensitive Compare mit Länge on Mon, 06 Dec 2010 10:21:20 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>// Wenn length &gt; kürzester String ---&gt; false</p>
</blockquote>
<p>würde ich als Fehler ansehen. Weil wenn beide Strings identisch sind, aber kleiner als length, gibt es ein false.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990330</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990330</guid><dc:creator><![CDATA[BigNeal]]></dc:creator><pubDate>Mon, 06 Dec 2010 10:21:20 GMT</pubDate></item><item><title><![CDATA[Reply to insensitive Compare mit Länge on Mon, 06 Dec 2010 12:01:41 GMT]]></title><description><![CDATA[<p>BigNeal schrieb:</p>
<blockquote>
<p>SeppJ schrieb:</p>
<blockquote>
<p>// Wenn length &gt; kürzester String ---&gt; false</p>
</blockquote>
<p>würde ich als Fehler ansehen. Weil wenn beide Strings identisch sind, aber kleiner als length, gibt es ein false.</p>
</blockquote>
<p>Ja, das fällt unter &quot;Ich verstehe nicht so ganz wozu das gut sein soll&quot;. Vorher hatte ich stattdessen<br />
<code>length = std::min(std::min(lhs.size(), rhs.size()), length);</code><br />
Dies ist dann wohl eher das was du meinst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990368</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990368</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 06 Dec 2010 12:01:41 GMT</pubDate></item><item><title><![CDATA[Reply to insensitive Compare mit Länge on Mon, 06 Dec 2010 17:17:37 GMT]]></title><description><![CDATA[<p><a href="http://fara.cs.uni-potsdam.de/~kaufmann/?page=GenCppFaqs&amp;faq=stricmp#Answ" rel="nofollow">http://fara.cs.uni-potsdam.de/~kaufmann/?page=GenCppFaqs&amp;faq=stricmp#Answ</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990608</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990608</guid><dc:creator><![CDATA[bens]]></dc:creator><pubDate>Mon, 06 Dec 2010 17:17:37 GMT</pubDate></item></channel></rss>