I have a Django site that contains only English language strings. I'll be localising this to other languages. I haven't set any sort of file encoding options. Do need to convert all my Python code to UTF-8? is this a good practice? If so, do I need to actually convert the file to be UTF-8 or do I simply need to add this snippet to each of my Python files # -*- coding: utf-8 -*-
Thanks.
The
# coding: utf-8
line is only necessary for files which contain special characters directly. Depending on how you want to achieve l10n, you have to take care how you process the strings.In Python2, you should use
unicode()
objects, while in Python3, normalstr()
ings are the thing to use.