e**n 发帖数: 10 | 1 I wrote a small program to display Chinese, but I can not display Chinese
correct.
Here is my code:
try
{
String s1 = "讨论";
JLabel jlTemp = new JLabel("Display: " + s1);
}
catch(Exception e)
{
}
In this case, the JLabel display garbage on the screen.
try
{
String s1 = "讨论";
String s2 = new String(s1.getBytes(), "GBK");
JLabel jlTemp = new JLabel("Display: " + s2);
}
catch(Exception e)
}
In this case, the JLabel display "????" on the screen.
Can someone tell me where my proble |
f********h 发帖数: 149 | 2 look at the font property file under $JAVA_HOME/jre/lib
you need to specify the chinese font there.
google bah.
【在 e**n 的大作中提到】 : I wrote a small program to display Chinese, but I can not display Chinese : correct. : Here is my code: : try : { : String s1 = "讨论"; : JLabel jlTemp = new JLabel("Display: " + s1); : } : catch(Exception e) : {
|
e**n 发帖数: 10 | 3 The font property is not the problem.
I found an example using Chinese in "\u6839\u636e" format. If I use s1 =
"\u6839\u636e" in my program, I can display it in Chinese correctly. But the
problem is, how am I going to implement? How can I convert all Chinese into
\uxxxx format?
【在 f********h 的大作中提到】 : look at the font property file under $JAVA_HOME/jre/lib : you need to specify the chinese font there. : google bah.
|
f********h 发帖数: 149 | 4 did you set up correct encoding in your code?
【在 e**n 的大作中提到】 : The font property is not the problem. : I found an example using Chinese in "\u6839\u636e" format. If I use s1 = : "\u6839\u636e" in my program, I can display it in Chinese correctly. But the : problem is, how am I going to implement? How can I convert all Chinese into : \uxxxx format?
|
w********c 发帖数: 2632 | 5 native2ascii
Chinese
【在 e**n 的大作中提到】 : The font property is not the problem. : I found an example using Chinese in "\u6839\u636e" format. If I use s1 = : "\u6839\u636e" in my program, I can display it in Chinese correctly. But the : problem is, how am I going to implement? How can I convert all Chinese into : \uxxxx format?
|
e***g 发帖数: 158 | 6 then it's source file encoding problem. your editor uses one encoding to
to save file, probably GB, but javac doesn't know that. check javac
command line options to tell it the encoding.
【在 e**n 的大作中提到】 : The font property is not the problem. : I found an example using Chinese in "\u6839\u636e" format. If I use s1 = : "\u6839\u636e" in my program, I can display it in Chinese correctly. But the : problem is, how am I going to implement? How can I convert all Chinese into : \uxxxx format?
|
t****s 发帖数: 141 | 7 Also, unless you specify it, default encoding is based on your platform.
【在 e***g 的大作中提到】 : then it's source file encoding problem. your editor uses one encoding to : to save file, probably GB, but javac doesn't know that. check javac : command line options to tell it the encoding.
|