Search code examples
pythonlinuxunicode

Encoding and decoding Portuguese word in python in linux envrionment


This is my function to encode and decode the Portuguese word:

def decoded_string(input_string):
    return input_string.encode('utf-8').decode('unicode_escape').encode('latin-1').decode('utf-8')

This is the output in windows: Mario Exportação

But in Linux, it is showing this output: Mario Exportação

Windows is my local machine and Linux is our server machine. I don't know why it's not working there and I even added RUN apt-get install -y fonts-dejavu in my docker container to support the Portuguese


Solution

  • I hope you are expecting on sub process in python. Actually you need add -utf8 flag at the end of the cmd... This works only on Linux environment, whereas in windows it will work fine without the flag

    openssl req -new -key /app/cert/sign.key -out /app/temp/cert-csr.pem -subj "/C=IN/ST=Coimbatore /L=India/O=Tech /OU=Técnico/CN=Mãnoj Kumar " -utf8