Mail Archives: djgpp/2001/09/23/22:02:53
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 -