How to set encoding ENV in docker?

I have a folder, some of the files in the folder has a Chinese name. I have tried the following code in docker.

import os
path = os.getcwd()
file_list = os.listdir(path)
for f in file_list:
    print(f.encode('utf-8').decode('utf-8', 'ignore'))

Unfortunatelly, the file which contains Chinese cannot revert to its raw in this way. I have tried the same code in my mac and it works well. Which is to say, it’s a ENV issue. I have tried to add ENV LANG C.UTF-8 in my Dockerfile which doesn’t work as well. The locale command in my docker is

LANG=C.UTF-8
LANGUAGE=
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_PAPER="C.UTF-8"
LC_NAME="C.UTF-8"
LC_ADDRESS="C.UTF-8"
LC_TELEPHONE="C.UTF-8"
LC_MEASUREMENT="C.UTF-8"
LC_IDENTIFICATION="C.UTF-8"
LC_ALL=

Anyone can help me out?

Source: Python-3x Questions

LEAVE A COMMENT