delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/09/23/22:02:53

From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Possible bug
Date: 24 Sep 2001 01:51:41 GMT
Organization: Cornell University
Lines: 88
Sender: asu1 AT cornell DOT invalid (on slip-32-102-40-118.ny.us.prserv.net)
Message-ID: <Xns9125DE5132297ASINANUNUR@132.236.56.8>
References: <004601c142e7$6f0a2920$323647a1 AT robert> <1pkoqt4ocnvr400nklea28vr51no8tkbsh AT 4ax DOT com> <9oi2nc$1jc$1 AT barcode DOT tesco DOT net> <o6bqqt8gaki7361smv823to2kbd8ls11il AT 4ax DOT com> <1001244576 DOT 694282 AT queeg DOT ludd DOT luth DOT se> <jonsqtcta5q49o8eld6b6rbaithusd38k9 AT 4ax DOT com>
NNTP-Posting-Host: slip-32-102-40-118.ny.us.prserv.net
X-Trace: news01.cit.cornell.edu 1001296301 17405 32.102.40.118 (24 Sep 2001 01:51:41 GMT)
X-Complaints-To: usenet AT news01 DOT cit DOT cornell DOT edu
NNTP-Posting-Date: 24 Sep 2001 01:51:41 GMT
User-Agent: Xnews/4.06.22
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Radical NetSurfer wrote in news:jonsqtcta5q49o8eld6b6rbaithusd38k9 AT 4ax DOT com:

> My only advice is use caution when using DJGPP and
> checking for, and changing CASE of a string.

Mostly because DJGPP only implements the C and POSIX locales as Eli pointed 
out some time ago. By the way, I have looked at the source code, and looked 
into how *nix systems as well as cygwin implements this, and it seems like 
more work than I can do at this time.
 
> strupr/strlwr, toupper/tolower,
> and especially,
> isalpha, isupper/islower
> should have always understood what an ALPHABETIC
> character is, and what most certainly is NOT an alphabetic
> character! sheesh!

I don't understand this. The small program included below has no problem in 
this regard. Exactly what is the problem?

>>: IT WAS A ROUTINE TO FILTER AND RENAME file names
>>: from web-site (and usenet) downloads, that contained "freaky" foreign
>>: and just dump-a** characters. 

i don't know what those characters are and i am curious to understand what 
specifically the problem is. can you post an example?

sample program to test toupper and isalpha below:

#include <ctype.h>
#include <stdio.h>

static const unsigned char* get_table(void)
{
	static unsigned char table[256];
	static int initialized;
	int i;

	if( initialized == 0 )
	{
		for( i = 0; i < 256; ++i)
			table[i] = (unsigned char) i;
		initialized = 1;
	}

	return table;
}

static void dump_toupper(const unsigned char* table)
{
	int i;

	for( i = 0; i < 256; ++i)
		printf("Code: %2.2X\tCharacter: %c\ttoupper: %c\n", 
				table[i], table[i], toupper(table[i]));

	return;
}

static void dump_isalpha(const unsigned char* table)
{
	int i;

	for( i = 0; i < 256; ++i)
		if( isalpha(table[i]) )
			printf("Code: %2.2X\tAlphabetic Character: %c\n", 
				table[i], table[i]);
	return;
}

int main(void)
{
	printf("Convert to upper case: \n");
	dump_toupper(get_table());

	printf("Print alphabetic characters:\n");
	dump_isalpha(get_table());	

	return 0;
}	




-- 
--------------------------------
A. Sinan Unur
http://www.unur.com/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019