Dear François

I checked Django's encoding again.

locale.getpreferredencoding() is
ANSI_X3.4-1968

sys.getdefaultencoding() is
ascii

2014年5月5日月曜日 20時12分52秒 UTC+9 Sugita Shinsuke:
>
> Dear François Schiettecatte 
>
> Hello.
> Thank you for replying.
>
> I checked  sys.getdefaultencoding() in Django and pure Python of the 
> server.
>
> Django returns 'ascii'.
> And, Python returns 'ascii' too.
>
> I also checked your link, 
> http://stackoverflow.com/questions/1473577/writing-unicode-strings-via-sys-stdout-in-python
>
> I checked the locale.getpreferredencoding().
>
> Django returns 'ascii'.
> But, Python returns ''UTF-8''.
> It is different of them.
>
> So, is it some possibility of the cause of my probrem?
> If it is the cause. Can I change encode type of 
> locale.getpreferredencoding?
>
> WBR Shinsuke
>
>
> 2014年4月27日日曜日 23時50分55秒 UTC+9 François Schiettecatte:
>>
>> You should check the encoding of stdout when running from django, I 
>> suspect that it is plain ascii rather than utf-8 which is what you are 
>> probably getting when running standalone. Check sys.getdefaultencoding(). 
>>
>> Note that this has nothing to do with django, just the way stdin/stdout 
>> are set up depending on how your script is running. 
>>
>> Also see: 
>>
>>         
>> http://stackoverflow.com/questions/1473577/writing-unicode-strings-via-sys-stdout-in-python
>>  
>>         
>> http://stackoverflow.com/questions/15740236/stdout-encoding-in-python 
>>         
>> http://stackoverflow.com/questions/492483/setting-the-correct-encoding-when-piping-stdout-in-python
>>  
>>
>> François 
>>
>> On Apr 27, 2014, at 2:13 AM, Sugita Shinsuke <shin...@gmail.com> wrote: 
>>
>> > Hi there 
>> > 
>> > I’d like to run Java code via Django. 
>> > 
>> > The Java code, javaprogram use like below. 
>> > 
>> > — 
>> > java javaprogram [text] [file_name] 
>> > — 
>> > 
>> > text is parameter. multi-byte character is also okey. 
>> > file_name is generate file name. 
>> > 
>> > So, I run the stand-alone Python program like below could run fine. 
>> > — 
>> > java_file = ‘javaprogram’ 
>> > file_name = ‘filename’ 
>> > text = ‘あいうえお’ #Japanese character 
>> > java_file_path = ‘/path/to/‘ 
>> > class_path = ‘-cp ' + java_file_path 
>> > 
>> > cmd = “java {0} {1} {2} {3}".format(class_path, java_file, text, 
>> file_name) 
>> > 
>> > import subprocess 
>> > proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, 
>> stderr=subprocess.STDOUT) 
>> > — 
>> > 
>> > But, I run same program in Django. 
>> > It couldn’t work. However, if text is English, it works fine. 
>> > 
>> > What is different of handling character code between pure Python and 
>> Django? 
>> > And, could you tell me how to resolve it? 
>> > 
>> > Thank you. 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> Groups "Django users" group. 
>> > To unsubscribe from this group and stop receiving emails from it, send 
>> an email to django-users...@googlegroups.com. 
>> > To post to this group, send email to django...@googlegroups.com. 
>> > Visit this group at http://groups.google.com/group/django-users. 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/cd081056-2a39-40f5-94c8-7b470bf827ea%40googlegroups.com.
>>  
>>
>> > For more options, visit https://groups.google.com/d/optout. 
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9cb6612a-57cc-4b80-a0ae-93891d8a6212%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to