On Thu, May 8, 2014 at 5:05 AM, Sugita Shinsuke <
shin...@gmail.com> wrote:
> Hello Tom Evans
>
>
>> plain single and double quotes - " and ', not “ and ‘.
> My e-mail client is Gmail web client.
>
>>What version of Python? 2.x or 3.x?
> Python version is 2.7.5
> And, Django version is 1.3.7
Django 1.3.7 is very old, it has known security holes in it and is not
maintained. What I talk about from here on down is not relevant for
1.3 - upgrade to at least 1.6.
In Python 2, you should mark your strings as unicode if they contain
anything other than ascii.
u'This is a unicode string'
'This is a byte string'
The characters within the string should be in the encoding specified
for the current file. See:
https://docs.python.org/2/howto/unicode.html#unicode-literals-in-python-source-code
Unicode strings are converted to the correct encoding for your
environment when output (running a command "outputs" the string to the
shell).
So, if you want your management command to output UTF-8:
1) Mark the strings in your program as unicode
2) Mark the files containing unicode string literals to denote the
character encoding used by the string literals
3) Ensure the environment that django is run in has the locale
correctly specified.
4) Ensure your management command either:
a) Activates a fixed language prior to outputting unicode or
b) Instructs django to use locale from the environment
See
https://docs.djangoproject.com/en/1.6/howto/custom-management-commands/#management-commands-and-locales
Cheers
Tom