空
空山新雨
Unregistered / Unconfirmed
GUEST, unregistred user!
[!]转了以后的中文可以在label,list中正常显示,但是在用Graphcis.drawString()的时候,画出来的是乱码,
转码代码如下:
String encoding = "GB2312";
try {
int curLength = 0;
StringBuffer buffer = new StringBuffer();
char[] buf = new char[1024];
InputStreamReader isr = new InputStreamReader(typeFile.openStream(), encoding);
while (curLength != -1) {
Arrays.fill(buf, '/0');
curLength = isr.read(buf, 0, buf.length);
buffer.append(buf);
}
return new BufferedReader(new StringReader(
new String(buffer.toString().getBytes(encoding), "ISO8859_1")));
} catch (UnsupportedEncodingException e) {
throw new ConfigException(this, encoding + " not supported", "", 0);
}
绘画代码如下:
public void paint(Graphics g) {
g.setColor(borderColor);
g.setFont(new Font("MingLiU", Font.PLAIN, 12));
//这一句要不要都错
g.drawRect(0, 0, this.getWidth() - 1, this.getHeight() - 1);
g.drawString(" " + tipString + " ", 0, this.getHeight() - 4);
}
请问怎么可以画出正常的中文?多谢各位赐教。
转码代码如下:
String encoding = "GB2312";
try {
int curLength = 0;
StringBuffer buffer = new StringBuffer();
char[] buf = new char[1024];
InputStreamReader isr = new InputStreamReader(typeFile.openStream(), encoding);
while (curLength != -1) {
Arrays.fill(buf, '/0');
curLength = isr.read(buf, 0, buf.length);
buffer.append(buf);
}
return new BufferedReader(new StringReader(
new String(buffer.toString().getBytes(encoding), "ISO8859_1")));
} catch (UnsupportedEncodingException e) {
throw new ConfigException(this, encoding + " not supported", "", 0);
}
绘画代码如下:
public void paint(Graphics g) {
g.setColor(borderColor);
g.setFont(new Font("MingLiU", Font.PLAIN, 12));
//这一句要不要都错
g.drawRect(0, 0, this.getWidth() - 1, this.getHeight() - 1);
g.drawString(" " + tipString + " ", 0, this.getHeight() - 4);
}
请问怎么可以画出正常的中文?多谢各位赐教。