Subject: luit 2.0 on Alpine Linux cannot convert Chinese charsets (GBK/GB2312/GB18030) correctly

From: nvim <[email-masked]>
Date: Fri, 27 Oct 2023 23:18:44 +0800

Greetings,

I was trying to use Docker to deploy an application which uses a SSH client
to log on a Chinese BBS (Bulletin Board System). Usually Chinese BBS use
GBK/GB2312/GB18030 charset, so I need `Luit` (
https://invisible-island.net/luit/)  to convert the output text for UTF-8
terminals. At first, I deployed my app on the Debian system, everything
worked fine (by the way. Debian 11 has no Luit 2.0, I need to build it from
source, while on Debian 12, Luit 2.0 has been included in the package
repository). Then I tried to deploy it on Alpine. I still need to build
Luit 2.0 from source. However, this time, the text displayed in the
terminal looks like garbled text, closer to Korean than Chinese.

*My question is, is this an Alpine Chinese charset encoding support problem
or a Luit problem. And is there any locale configuration I need to do on
Alpine? Could you please kindly shed some light on this please? Thanks
in advance.*

*On Alpine:*

*I installed musl musl-utils musl-locales tzdata.*

/ # cat /etc/issue
Welcome to Alpine Linux 3.18
Kernel \r on an \m (\l)

/ # ls /usr/share/locale/
cs_CZ  de_DE  en_US  fi_FI  it_IT  nl_NL  pt_PT  sr_RS
de_CH  en_GB  es_ES  fr_FR  nb_NO  pt_BR  ru_RU  sv_SE
*[No Chinese locale here.]*

/ # locale -m
ASCII
UTF-8
*[No Chinese char maps.]*

/ # iconv -l
UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF32-LE, UCS-2BE, UCS-2LE, WCHAR_T,
US_ASCII, ISO8859-1, ISO8859-2, ISO8859-3, ISO8859-4, ISO8859-5,
ISO8859-6, ISO8859-7, ...
*[No Chinese GBK/GB2312/GB18030 charset encoding here.]*

/ # luit -encoding GB18030 ssh [email-masked]
(incorrect conversion on Alpine)

*On Debian:*

# cat /etc/issue
Debian GNU/Linux 11 \n \l

# locale -m | grep GB
GB18030
GB2312
GBK
GB_1988-80

# iconv -l | grep GB
CN-GB//
CSGB2312//
CSISO58GB1988//
EBCDIC-CP-GB//
GB//
GB2312//
GB13000//
GB18030//
GBK//
GB_1988-80//
GB_198880//
ISO646-GB//

# luit -encoding GB18030 ssh [email-masked]
(expected conversion on Debian)

Thanks,
David.