[英]JLabel: issue with accented letters
我从JSON Web服务读取了一些字符串数据。
当我将结果字符串(带有重音字母)放入JLabel
我看到以下结果:
但字符串应包含: Lèttèrèàccèntàtè-ààèèììò
我使用此代码声明JLabel
:
JLabel descriptionLabel = new JLabel(myString);
如果尝试将此字符串放入.txt文件,请读取正确的字符串( Lèttèrèàccèntàtè-ààèèììò )。
这与我使用的字符集有关吗?
这对我有用,请检查它是否也对您有用,我们可以从那里继续。
public class AccentedLabel extends JFrame {
public AccentedLabel() {
JLabel label = new JLabel("áéêè");
add(label);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setVisible(true);
}
public static void main(String[] args) {
new AccentedLabel();
}
}
编辑 :现在尝试用以下unicode字符串替换字符串中的所有重音字符,并将它们设置在标签中。
á \u00e0 Á \u00c0
à \u00e1 À \u00c1
â \u00e2 Â \u00c2
é \u00e9 É \u00c9
è \u00e8 È \u00c8
ê \u00ea Ê \u00ca
î \u00ee Î \u00ce
ç \u00e7 Ç \u00c7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.