UnicodeEncodeError: 'ascii' codec can't encode characters in position 30-37
问题记录
环境: arm 下
docker 中 UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 30-37
原因:编码问题
locale 查看编码
LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=
系统编码没问题
解决办法:
dockerfile 中增加:
RUN yum install kde-l10n-Chinese -y && \
yum install glibc-common -y && \
localedef -c -f UTF-8 -i zh_CN zh_CN.utf8
ENV LC_ALL zh_CN.UTF-8