S
S
Sergey2017-10-13 17:17:13
Django
Sergey, 2017-10-13 17:17:13

How to translate the encoded Russian file name by nginx back into the Russian file name on the Django(python) side?

How to translate the encoded Russian file name by nginx back into the Russian file name on the Django(python) side?
There is a file: Hi.mp4
nginx encodes it to %D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82.mp4
and I can't recode it back into Russian
characters do in python "Hi".encode('utf8')
then I get b'\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82'
and it's different from what it sends nginx

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
gill-sama, 2017-10-13
@SereyK

from urllib import parse
parse.unquote('%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82.mp4')

Well, let's say this.

W
Wexter, 2017-10-13
@Wexter

and who told you that nginx encodes it? this is called URL Encoding, is converted on the client side. https://www.google.ru/search?q=django+url+decode

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question