Page MenuHomeFreeBSD

Fix various issues with Chinese locales.
ClosedPublic

Authored by delphij on Dec 30 2018, 8:01 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 11:02 PM
Unknown Object (File)
Wed, Nov 20, 5:45 PM
Unknown Object (File)
Tue, Nov 19, 1:03 AM
Unknown Object (File)
Mon, Nov 18, 12:26 AM
Unknown Object (File)
Mon, Nov 11, 12:58 PM
Unknown Object (File)
Thu, Nov 7, 12:17 AM
Unknown Object (File)
Tue, Nov 5, 7:07 PM
Unknown Object (File)
Oct 22 2024, 11:30 PM
Subscribers

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 - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 21779
Build 21053: arc lint + arc unit

Event Timeline

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

delphij added a reviewer: lwhsu.
delphij added a reviewer: loader.
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.