Page MenuHomeFreeBSD

Fix various issues with Chinese locales.
ClosedPublic

Authored by delphij on Dec 30 2018, 8:01 AM.

Details

Summary

Fix various issues with Chinese locales:

  • Correct short weekday names to use only one Chinese character.
  • for zh_CN locales: use Arabic numerals for month names, matching the practice of all other CJK locales
  • Regenerate zh_CN.{GB2312,GBK} locales from zh_CN.UTF-8.

Reported by: ygy

Test Plan

run various time related utilities with LC_ALL=zh_{CN,HK,TW}.UTF-8

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

delphij created this revision.Dec 30 2018, 8:01 AM
delphij updated this revision to Diff 52421.Dec 30 2018, 8:03 AM

Properly set MIME type for zh_CN.UTF-8.src.

delphij updated this revision to Diff 52422.Dec 30 2018, 8:39 AM

Rebase after r342614.

delphij edited the summary of this revision. (Show Details)Dec 30 2018, 8:46 AM
delphij added a reviewer: lwhsu.
delphij added a reviewer: loader.
kevlo accepted this revision.Dec 30 2018, 1:53 PM
This revision is now accepted and ready to land.Dec 30 2018, 1:53 PM

I would think this would affect any program that calls strftime(3) with abbreviated weekday name (%a),
for example ps(1):

https://svnweb.freebsd.org/base/head/bin/ps/print.c?revision=335023&view=markup#l411

410             } else if (now - k->ki_p->ki_start.tv_sec < 7 * 86400) {
411                             (void)strftime(buf, buflen, "%a%H  ", tp);

then it would just print out a here instead of 周五:

% env LANG=zh_CN.UTF-8 ps auwwx | grep '[s]bin/sshd'
root 26612  0.0  0.0 20784  100  -  IsJ  五12    0:00.02 /usr/sbin/sshd

% env LANG=en_US.UTF-8 ps auwwx | grep '[s]bin/sshd'
root 26612  0.0  0.0 20784  100  -  IsJ  Fri12   0:00.02 /usr/sbin/sshd

I would think this would affect any program that calls strftime(3) with abbreviated weekday name (%a),
for example ps(1):
https://svnweb.freebsd.org/base/head/bin/ps/print.c?revision=335023&view=markup#l411

410             } else if (now - k->ki_p->ki_start.tv_sec < 7 * 86400) {
411                             (void)strftime(buf, buflen, "%a%H  ", tp);

then it would just print out a here instead of 周五:

% env LANG=zh_CN.UTF-8 ps auwwx | grep '[s]bin/sshd'
root 26612  0.0  0.0 20784  100  -  IsJ  五12    0:00.02 /usr/sbin/sshd
% env LANG=en_US.UTF-8 ps auwwx | grep '[s]bin/sshd'
root 26612  0.0  0.0 20784  100  -  IsJ  Fri12   0:00.02 /usr/sbin/sshd

The current representation is more problematic when the caller supplies a buffer that is shorter (for example, cal(1)), where the truncation would keep only one Chinese character. For example:

$ LANG=zh_CN.UTF-8 cal
      十二月 2018        
周 周 周 周 周 周 周  
                   1  
 2  3  4  5  6  7  8  
 9 10 11 12 13 14 15  
16 17 18 19 20 21 22  
23 24 25 26 27 28 29  
30 31

After patch:

      12月 2018
日 一 二 三 四 五 六
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31

On macOS Mojave, the weekday behavior of ps(1) is similar to FreeBSD (after patch).

This revision was automatically updated to reflect the committed changes.