[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tr '[:upper:]' '[:lower:]' -- misaligned construct
From: |
Jim Meyering |
Subject: |
Re: tr '[:upper:]' '[:lower:]' -- misaligned construct |
Date: |
Sun, 06 Jan 2008 15:30:45 +0100 |
"James Youngman" <address@hidden> wrote:
> On Jan 5, 2008 9:01 AM, Jim Meyering <address@hidden> wrote:
>> > That machine is running in an ISO-8859 locale on openSUSE 11.0 FACTORY:
>
> I can reproduce the problem on Debian (Lenny; version 2.7-3 of the
> locales package with LANG=en_US.iso-8859-1).
>
>> That locale definition has 3 more upper-case letters than lower-case,
>
> I think it's the other way around; more lower than upper case letters
> (there's a small error in the ternary conditional in the code you
Right. Good catch.
> posted). In the Latin-1 locale I mention above, the difference is
> only two characters:
>
> Char 181 µ: lower case. Equivalents: upper case equivalent is 181 µ: SAME
> Char 223 ß: lower case. Equivalents: upper case equivalent is 223 ß: SAME
FYI, I get three with debian unstable's locales-all 2.7-5.
Same with rawhide.
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <locale.h>
int
main ()
{
int n_upper = 0;
int n_lower = 0;
int i;
setlocale (LC_ALL, "");
for (i = 0; i < 256; i++)
{
printf ("%d %c: %s %s\n",
i, i, islower (i) ? " L" : "", isupper (i) ? " U" : "");
if (isupper (i))
++n_upper;
if (islower (i))
++n_lower;
}
printf ("u: %d\n", n_upper);
printf ("l: %d\n", n_lower);
return !(n_lower == n_upper);
}