Set an UTF-8 locale as default, not POSIX
未关闭
还没有人认领这个 Issue。
- 主要语言
- Dockerfile
- 星标
- 8.6k
- 派生
- 2k
- 平均合并
- 10 小时 19 分钟
- 30 天内合并 PR
- 16
描述
Problem
The default locale of the node image is POSIX:
$ docker run --rm node:latest locale
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
node:19 has the following locales built-in:
$ docker run --rm node:19 locale -a
C
C.UTF-8
POSIX
The POSIX locale doesn't recognize UTF-8 (wc -m counts characters, not bytes).
$ docker run --rm node:latest bash -c 'echo -n 💩 | wc -m'
4
$ docker run --rm node:latest bash -c 'echo -n 💩 | LC_CTYPE=C.UTF-8 wc -m'
1
It is possible to manually enable C.UTF-8:
$ docker run --rm --env LC_CTYPE=C.UTF-8 node:latest bash -c 'echo -n 💩 | wc -m'
1
However in 2023, who doesn't need a locale supporting Unicode? ASCII is a bad default as it doesn't match a 2023 development environment.
Solution
Set LC_CTYPE=C.UTF-8 in the node image. Probably in file /etc/environment.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
检查 Node image 如何配置 /etc/environment,然后运行所报告的命令 docker run --rm node:latest locale 和 locale -a,以确认可用的 locale。将默认的 LC_CTYPE 设置为 C.UTF-8,并验证 wc -m Unicode 示例在不传递环境覆盖的情况下报告一个字符。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- docker
- 领域
- infrastructure
- Issue 类型
- 功能
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 55/100