From 3447262656536083685
X-Google-Thread: f78e5,e1d72e3830635ee
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!local01.nntp.dca.giganews.com!nntp.speakeasy.net!news.speakeasy.net.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 01 Aug 2005 01:30:02 -0500
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Delivered-To: std-c++@ucar.edu
From: Dave Thompson <david.thompson1@worldnet.att.net>
Newsgroups: comp.std.c++
Subject: Re: std::tolower - which one should be visible?
Message-ID: <5rcre1d6fnp95v6fiavmiv46cnqbu9s9c3@4ax.com>
References: <dbqg7i$fa2$1@sunnews.cern.ch> <1122301061.460975.257060@g49g2000cwa.googlegroups.com> <42e55374$1_3@news.bluewin.ch>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@worldnet.att.net
Organization: AT&T Worldnet
X-Greylisting: NO DELAY (Relay+Sender autoqualified);
	processed by UCSD_GL-v1.3 on mailbox4.ucsd.edu;
	Sun, 31 July 2005 22:37:04 -0700 (PDT)
X-Spamscanner: mailbox4.ucsd.edu  (v1.6 Apr  6 2005 07:48:50, 0.0/5.0 3.0.0)
X-MailScanner: PASSED (v1.2.8 90701 j715b03C000446 mailbox4.ucsd.edu)
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
Date: Mon,  1 Aug 2005 01:27:34 CST
Lines: 36
NNTP-Posting-Host: 65.182.171.162
X-Trace: sv3-qBkcS+CCZzaCfAbTiC3qreimJf12TPepwALV6krHaxjY6VsMXdCt5gKbfxz5t8pfi6G6QASwWX7j65c!FGIao8TGMtwY4z2lQiaCpvCtaeA5o1W4p/M+Ft+SgxJxIyHlUMDn+otBfmlpnymUhWFTiz1eCj8x!Z+puQU6CtoJSWH+OMd8swnCYhOji
X-Complaints-To: abuse@speakeasy.net
X-DMCA-Complaints-To: abuse@speakeasy.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.32
Xref: g2news1.google.com comp.std.c++:1579

On Mon, 25 Jul 2005 16:06:40 CST, Maciej Sobczak <no.spam@no.spam.com>
wrote:

> kanze@gabi-soft.fr wrote:
> 
> > Except that calling the standard C version of tolower with a
> > char argument is undefined behavior, of course.
> 
> I don't understand this assertion. The argument of C version of tolower 
> has to be representable by unsigned char or equal to EOF. Staying within 
> the ASCII range [0..127], all character codes seem to fit this requirement.
> 
> What's the real problem?

ASCII or slightly more generally 0..127 is OK, but there was nothing
above AFAICS saying the data is so restricted, nor is it in general.
"Plain" char in C and C++ can be signed or unsigned at the
implementation's option; _if_ it is signed _and_ any actual value
stored is negative (and != EOF) that's the problem. 

The conventional solution on comp.lang.c is to cast the char value to
unsigned char, or to use a pointer to unsigned char. The latter is
less convenient with std::string, so the best solution is probably

inline char my_tolower (char x) /* or scoped:: as you wish */ 
{ return std::tolower( static_cast<unsigned char>(x) ); }


- David.Thompson1 at worldnet.att.net

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



