I developed jnlp applet which prints out the user input.
When I put odd number of non-english characters(eg: chinese), chrome browser prints out the last character as question mark.
input : 가 output : 가��
I checked on java console that the character is correct.
It must be bug in communication of applet to chrome browser.
IE prints out correctly.
I can resolve the issue by appending white space on applet and remove it on java script.
Anyone has any clue on the issue?
Codes are as follows.
*MainApplet.Java*
public class MainApplet extends JApplet implements JSInterface{//, Runnable {
public int stringOut(String sData) {
OutData = sData;
return 0;
}
}
*js File*
function TSToolkitRealWrapper ()
{
var OutData;
var OutDataNum;
}
var TSToolkit = new TSToolkitRealWrapper();
var attributes = { id:'TSToolkitReal',code:'com.multibrowser.test.MainApplet', width:100, height:100} ;
var parameters = {jnlp_href: getContextPath() + '/download/pkitoolkit.jnlp',
separate_jvm:true, classloader_cache:false} ;
TSToolkitRealWrapper.prototype.stringOut=function(str)
{
var nRet = TSToolkitReal.stringOut(str) ;
this.OutData= TSToolkitReal.OutData;
return nRet;
}
*HTML*
<SCRIPT language=javascript>
<!--
function StringOut(form)
{
var data = form.data.value;
var nRet = 0;
var base64Data;
nRet = TSToolkit.stringOut(data);
if (nRet > 0)
{
alert(nRet + " : " + TSToolkit.GetErrorMessage());
}
else
{
form.data1.value = TSToolkit.OutData;
}
}
-->
</SCRIPT>
*jnlp*
<?xml version="1.0" encoding="UTF-8"?>
<jnlp href="cmp.jnlp">
<information>
<title>MultiBrowser</title>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.6+" />
<jar href="MultiBrowser.jar"/>
</resources>
<applet-desc height="200" main-class="com.multibrowser.test.MainApplet" name="MainApplet" width="200"/>
</jnlp>
I asked in several web browser forums, but there are no answers yet.
Difference between Windows and Linux is file.encoding value. Windows(ms959) and Linux(UTF-8).
I can't figure how to set the file.encoding value though.
Below didn't work. When I press 's' in java console, it still prints file.encoding=MS949.
<?xml version="1.0" encoding="UTF-8"?>
<jnlp href="pkitoolkit.jnlp">
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.6+" java-vm-args="-Dfile.encoding=UTF-8" />
<property name="file.encoding" value="UTF-8"/>
IE prints out correctly
Emm...
You give less details... anyway if you can enter chinese characters in your browser but get some rubbish on applet output means that your internet broswer supports chinese but your applet doesn't;
I presume you should watch closer to your client machine JRE encoding settings because it maybe doesn't support chinese encoding by default so maybe your applet should have some manual localization control...
A. I can advise dig deeper into applet Locale user language settings...
I suspect that the file.encoding is the problem, if you look at my own answers below. I couldn't find how to set the encoding though
B. You can use static code like this to set property (put it at the very beginning of your applet code)
static {
System.setProperty("file.encoding", "UTF-8"); }
C.
When I put odd number of non-english characters(eg: chinese), chrome browser prints out the last character as question mark.
and...
encoding is ms949 and the jre version is 1.7.0_17
...the conception is pretty weird :S If you have your chrome with korean letters support and it is ms949 as your client machine default encoding but at the same time you want to make your applet support utf-8 and output korean characters correctly with JS back to your ms494 encoded web page I do suspect you do face some kind of incompatible encodings %P
So first, I do recommend to make your applet web page support utf-8 encoding instead of the default ms494 because I suppose the applet and its web page cp(s) might be incompatible :S
Report if that helped
I had the same problem about 2 months ago at J2ME, I solve problem with using String.trim() method, if your text doesn't have white space at the end you could try that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With