Saturday, April 26, 2014

What is different of handling character code between pure Python and Django?

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+unsubscribe@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/cd081056-2a39-40f5-94c8-7b470bf827ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment