Python os.stat and unicode file names

前端 未结 5 836
我寻月下人不归
我寻月下人不归 2020-12-31 05:05

In my Django application, a user has uploaded a file with a unicode character in the name.

When I\'m downloading files, I\'m calling :

os.path.exists         


        
5条回答
  •  猫巷女王i
    2020-12-31 05:40

    Change your http server to use UTF-8 locale. For example, I use apache2 on CentOS. I changed /etc/sysconfig/httpd locale setting by HTTPD_LANG:

    # CentOS use /etc/sysconfig/httpd to config environment variables.
    #
    # By default, the httpd process is started in the C locale; to
    # change the locale in which the server runs, the HTTPD_LANG
    # variable can be set.
    #
    # HTTPD_LANG=C
    HTTPD_LANG=en_US.UTF-8  # you can change to your locale.
    

提交回复
热议问题