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 <shinr...@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+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/cd081056-2a39-40f5-94c8-7b470bf827ea%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: Message signed with OpenPGP using GPGMail