Re: <ctype.h> toLower()

From: Mike Wahler (mkwahler_at_mkwahler.net)
Date: 11/18/03


Date: Tue, 18 Nov 2003 19:40:43 GMT


"ellie fant" <pcrcutitout1000011@uko2.co.uk> wrote in message
news:1069183013.607789@news.minx.net.uk...
> Richard heathfield wrote:
> > No, that would be very petty. You did indeed point out an error in one
of
> my
> > articles, for which I'm grateful. Why not be grateful that I have
pointed
> > out an error in yours?
> >
>
> In reality 99% of all working code is not portable

Non-sequitur. This newsgroup is about ISO standard C, not
about any 'working code'.

> so lets stop trying to
> pretend portable code is the only code that is correct.

It's the only code which is correct in the context of
comp.lang.c. Did you not read the group's welcome message?

> Do the rules of this newsgroup state that we must only discuss portable
code

Yes. Please see:
http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html

Nonportable code is necessarily platform-dependent, and
there already exist newsgroups which discuss those platforms
and their issues.

> or is this something you have personally decided to include?

Richard (and I, and I presume most/many others who participate
here) have 'personally decided' to follow the newsgroup guidelines
stated in the link I cite above.

>Is code wrong
> because it is not portable?

It's not 'wrong', but neither is it topical for comp.lang.c

>
> So what is WRONG with OR'ing an uppercase ASCII alpha character with 20h
to
> make it lowercase?

What's wrong is that a portable C program cannot assume its
host system uses a particular character set. The only gurantee
made my the standard language about the encoding values of characters
is that the digit characters 0 - 9 have sequential values.

> A quasirandom value as you called it.- lol

A good term for referring to it imo.

> I'll tell you what's good about it. It's more efficient that using tolower
> function.

You don't know that. I suspect that for implementations on systems
that do use ASCII, the library functions having to do with changing
case do indeed take advantage of the particular attributes of the
host character set, such as the 'symmetry' of ASCII alpha character
codes. The implementation is allowed to take such advantage of
intimate knowledge of the platform, portable source code is not.

> And do you still say that it doesn't work? because it does.

No it does not. Try expanding your test data set to include
*all* possible character value inputs.

> If you can genuinely point out an error with this method I will eat cows
> turd

Here's a fork. Eat up. :-) Richard has already pointed out
your errors.

>but the fact that it is not 100% portable is not an error.

"Error" means nothing without context. It is indeed an error
to post or suggest nonstandard code in comp.lang.c, since it's
not topical here.

Despite that, even on an ASCII system, your code *does not work*.

>
> So lets see you point out a real error rather than making one up out of
the
> blue.

Try feeding your function the string:

"ABC123 $100"

-Mike



Relevant Pages

  • Re: Chinese dictation
    ... Richard> to work out what the omitted prepositions and particles ... As easy as it is for you with English. ... "How to write that character / those characters?" ... Richard> belief that Chinese characters are arbitrary shapes. ...
    (sci.lang)
  • Re: Chinese dictation
    ... > Richard> don't know. ... >As easy as it is for you with English. ... > Richard> character. ... > Richard> belief that Chinese characters are arbitrary shapes. ...
    (sci.lang)
  • Re: Word count of minimum vocabulary
    ... >> the phonetic hints. ... Then, it's an ideograph, right? ... Richard> If that were so, why do you need to write the phonetic as ... Because it's then an integral part of the character. ...
    (sci.lang)
  • Re: Kensington runestone Vegetation)in the Scandinavian press
    ... >> Alaca created ... >>> Calling someone wrong is very easy. ... > But, although I like the character, I am not Richard. ... well richard is especially whipped. ...
    (sci.archaeology)
  • Re: A note on computing thugs and coding bums
    ... code is valid for any character set that is legal in C (which is a ... characters in the required source character set ... A String, in C Sharp or Java, can be redefined. ... allow programmers to handle some other data format, ...
    (comp.programming)

Loading