View Full Version : Chinese UTF8 characters problems in Quercus

10-22-2011, 10:35 AM
Hello I'm new to Quercus,recently we are trying to integrate java with php in our project and we met Chinese UTF8 characters problems in Quercus.

All files(.php,.java)are encoded in UTF-8.Resin version 4.0.23.Quercus version 4.0.18.

echo "Chinese中文<br/>";

The Chinese characters are garbled :eek:and the page are encoded by gbk...

Then I try configure resin.xml and set character-encoding to utf-8
It works,the Chinese characters display correctly!;)
and the page are encoded by utf-8:cool:

Then I try to call java method in php~

edit test.php

$demoService = spring_bean("demoServiceImpl");
$str=$demoService-> test("中文");
echo "中文:str from java:";
echo $str;

java method:

public String test(String str){
System.out.println("str from php:"+str);
return "中文";

The Chinese characters are ???? in java console #_#
Then I editresin-web.xml

<web-app xmlns="http://caucho.com/ns/resin">
<servlet-mapping url-pattern="*.php"

in java console,it's ok!
str from php:中文
But in web browser are still garbled
-?str from java:-?
Any suggestions?

01-05-2012, 07:02 AM
Or you can re-encode in java

String strInJava = new String(strFromPhp.getBytes("iso8859-1"), "utf-8");