[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Chinese problem in `cal`



>>>>> "hingwah" == hingwah  <hingwah.bbs@VOIDbbs.e-fever.org> writes:

    hingwah> It can be seen that the program just print out the first 2
    hingwah> character of the weekday, as 1 chinese chracter occupy 2 ASCII
    hingwah> character,so so 周一will become 周,周二will become 周...etc...

The corresponding code in ncal.c:

void
mkweekdays(struct weekdays *wds)
{
        int i, len;
        struct tm tm;
        char buf[20];

        memset(&tm, 0, sizeof(tm));

        for (i = 0; i != 7; i++) {
                tm.tm_wday = (i+1) % 7;
                strftime(buf, sizeof(buf), "%a", &tm);
                len = strlen(buf);
                if (len > 2)
                        len = 2;
                strcpy(wds->names[i], "   ");
                strncpy(wds->names[i] + 2 - len, buf, len);
        }
}

Note that strftime is used to get the weekname.  In man page of it, it
mentioned:

       %a     The abbreviated weekday name according to the  cur-
              rent locale.

It appears to me that the locale definition is at fault: we should not have
the word 周 there in the abbreviated weekday name, just like we don't have
the root "day" there in the English abbreviated weekday name.  When a normal
person see "日一二三四五六", he know we are talking about week names, and 周
is redundant.  If somebody sees an isolated 日, he probably don't know what
we are talking about.  But so what... even in English, if somebody talks
about Sun in isolated domains, he would think that we are talking about the
celestial object that makes the difference between day and night...

On the other hand, I'm wondering whether such "cutting" in ncal is
reasonable.  Think about it... what would happen if we are in a UTF8 locale,
where all Chinese characters are 3-octets long?

Regards,
Isaac.
-- 
| This message was re-posted from debian-chinese-big5@lists.debian.org
| and converted from big5 to gb2312 by an automatic gateway.

Attachment: pgpXwZVEGeThN.pgp
Description: PGP signature


Reply to: