0

Basically, when user uploads the file I am writing that file into NFS. But it gives an error 'ascii' codec can't encode characters in position 28-32: ordinal not in range(128)

I have tried to install Chinese locale and set it but it is not working

I am taking the file name as this but it is not working

file_name = file_name.encode('ascii').decode('unicode-escape')
Travis Webb
  • 14,688
  • 7
  • 55
  • 109
Vimox Shah
  • 99
  • 1
  • 9
  • I've found this [post](https://stackoverflow.com/questions/9942594/unicodeencodeerror-ascii-codec-cant-encode-character-u-xa0-in-position-20) that could be useful for you! – ericcco Oct 18 '19 at 10:59
  • Ascii does not support Chinese. You to use Unicode (utf-8). – John Hanley Oct 18 '19 at 14:20

1 Answers1

0

We were having the same issue on our Debian 11 server running Apache2. Our environment locale was UTF-8 but when testing it showed up on the browser as ASCII.

In our case, the solution was to change the /etc/apache2/envvars file and remove the # before . /etc/default/locale.

We found this solution at itekblog.com/ascii-codec-cant-encode-characters-in-position/

Anthony Petrillo
  • 365
  • 1
  • 4
  • 13