Should I ensure that all my web application code is UTF-8?

126 Views Asked by At

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.

1

There are 1 best solutions below

1
On BEST ANSWER

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, normal str()ings are the thing to use.