4394b61e02
2008-04-10 Benjamin Kosnik <bkoz@redhat.com> * doc/html/*: Regenerate. 2008-04-10 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> * doc/xml/manual/bitmap_allocator.xml: Improve wording a bit. * doc/xml/authors.xml: Fix typos. * doc/xml/faq.xml: Likewise. * doc/xml/manual/abi.xml: Likewise. * doc/xml/manual/allocator.xml: Likewise. * doc/xml/manual/appendix_contributing.xml: Likewise. * doc/xml/manual/backwards_compatibility.xml: Likewise. * doc/xml/manual/build_hacking.xml: Likewise. * doc/xml/manual/codecvt.xml: Likewise. * doc/xml/manual/concurrency.xml: Likewise. * doc/xml/manual/ctype.xml: Likewise. * doc/xml/manual/debug_mode.xml: Likewise. * doc/xml/manual/diagnostics.xml: Likewise. * doc/xml/manual/evolution.xml: Likewise. * doc/xml/manual/extensions.xml: Likewise. * doc/xml/manual/locale.xml: Likewise. * doc/xml/manual/messages.xml: Likewise. * doc/xml/manual/parallel_mode.xml: Likewise. * doc/xml/manual/status_cxx200x.xml: Likewise. * doc/xml/manual/strings.xml: Likewise. * doc/xml/manual/support.xml: Likewise. * doc/xml/manual/test.xml: Likewise. * doc/xml/manual/using.xml: Likewise. 2008-04-10 Benjamin Kosnik <bkoz@redhat.com> Johannes Singler <singler@ira.uka.de> * doc/xml/manual/parallel_mode.xml: Remove map/set bulk insertors. Correct omp_set_num_threads example. From-SVN: r134178
41 lines
4.3 KiB
HTML
41 lines
4.3 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Case Sensitivity</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content=" ISO C++ , library " /><link rel="start" href="../spine.html" title="The GNU C++ Library Documentation" /><link rel="up" href="bk01pt05ch13.html" title="Chapter 13. String Classes" /><link rel="prev" href="bk01pt05ch13.html" title="Chapter 13. String Classes" /><link rel="next" href="bk01pt05ch13s03.html" title="Arbitrary Character Types" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Case Sensitivity</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="bk01pt05ch13.html">Prev</a> </td><th width="60%" align="center">Chapter 13. String Classes</th><td width="20%" align="right"> <a accesskey="n" href="bk01pt05ch13s03.html">Next</a></td></tr></table><hr /></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="strings.string.case"></a>Case Sensitivity</h2></div></div></div><p>
|
||
</p><p>The well-known-and-if-it-isn't-well-known-it-ought-to-be
|
||
<a class="ulink" href="http://www.gotw.ca/gotw/" target="_top">Guru of the Week</a>
|
||
discussions held on Usenet covered this topic in January of 1998.
|
||
Briefly, the challenge was, “<span class="quote">write a 'ci_string' class which
|
||
is identical to the standard 'string' class, but is
|
||
case-insensitive in the same way as the (common but nonstandard)
|
||
C function stricmp()</span>”.
|
||
</p><pre class="programlisting">
|
||
ci_string s( "AbCdE" );
|
||
|
||
// case insensitive
|
||
assert( s == "abcde" );
|
||
assert( s == "ABCDE" );
|
||
|
||
// still case-preserving, of course
|
||
assert( strcmp( s.c_str(), "AbCdE" ) == 0 );
|
||
assert( strcmp( s.c_str(), "abcde" ) != 0 ); </pre><p>The solution is surprisingly easy. The original answer was
|
||
posted on Usenet, and a revised version appears in Herb Sutter's
|
||
book <span class="emphasis"><em>Exceptional C++</em></span> and on his website as <a class="ulink" href="http://www.gotw.ca/gotw/029.htm" target="_top">GotW 29</a>.
|
||
</p><p>See? Told you it was easy!</p><p>
|
||
<span class="emphasis"><em>Added June 2000:</em></span> The May 2000 issue of C++
|
||
Report contains a fascinating <a class="ulink" href="http://lafstern.org/matt/col2_new.pdf" target="_top"> article</a> by
|
||
Matt Austern (yes, <span class="emphasis"><em>the</em></span> Matt Austern) on why
|
||
case-insensitive comparisons are not as easy as they seem, and
|
||
why creating a class is the <span class="emphasis"><em>wrong</em></span> way to go
|
||
about it in production code. (The GotW answer mentions one of
|
||
the principle difficulties; his article mentions more.)
|
||
</p><p>Basically, this is "easy" only if you ignore some things,
|
||
things which may be too important to your program to ignore. (I chose
|
||
to ignore them when originally writing this entry, and am surprised
|
||
that nobody ever called me on it...) The GotW question and answer
|
||
remain useful instructional tools, however.
|
||
</p><p><span class="emphasis"><em>Added September 2000:</em></span> James Kanze provided a link to a
|
||
<a class="ulink" href="http://www.unicode.org/unicode/reports/tr21/" target="_top">Unicode
|
||
Technical Report discussing case handling</a>, which provides some
|
||
very good information.
|
||
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="bk01pt05ch13.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="bk01pt05ch13.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="bk01pt05ch13s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 13. String Classes </td><td width="20%" align="center"><a accesskey="h" href="../spine.html">Home</a></td><td width="40%" align="right" valign="top"> Arbitrary Character Types</td></tr></table></div></body></html>
|