java 如何在 JavaFX 中为非英语支持添加 UTF-8?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14091011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add UTF-8 for non english support in JavaFX?
提问by Erfan Jazeb Nikoo
I want to add UTF-8 Farsi characters in JavaFX but when I add a label with Persian content it shows some weird results.
我想在 JavaFX 中添加 UTF-8 波斯语字符,但是当我添加带有波斯内容的标签时,它显示了一些奇怪的结果。
Do I have to use a specific plugin or configuration to handle this issue?
我是否必须使用特定的插件或配置来处理这个问题?
回答by jewelsea
Persian is right to left?
波斯语是从右到左吗?
In which case you want to use a version of JavaFX with RTL support. That would be JavaFX 8 (included in JDK8). There is a preview available here.
在这种情况下,您希望使用具有RTL 支持的 JavaFX 版本。那将是 JavaFX 8(包含在 JDK8 中)。此处提供预览。
Make sure you have loaded and are using a fontwhich includes the glyphs for Persian characters.
Here is some sample JavaFX 8 codefor displaying something which looks to me like Persian script.
这是一些示例 JavaFX 8 代码,用于显示在我看来像波斯脚本的内容。
All other comments on this question regarding using and interpreting the correct character encoding are also valid.
关于这个问题的所有其他关于使用和解释正确字符编码的评论也是有效的。
回答by Kirill Yashuk
If you`re using ResourceBundle, make sure it reads property files with the right encoding.
如果您使用 ResourceBundle,请确保它以正确的编码读取属性文件。
回答by EKanadily
i faced the same issue ,the answer was that file encoding of my source code files was not UTF8 (i am using intellijidea 14) i converted them to UTF8 and it worked.
我遇到了同样的问题,答案是我的源代码文件的文件编码不是 UTF8(我使用的是 intellijidea 14),我将它们转换为 UTF8 并且它起作用了。
回答by leonbloy
Most probably your issue is not related with JavaFX but with some encoding messing. UTF-8 (which is not a set of languages, but a Unicode charset encoding) is fully supported in Java since ages. Do yourself a favour and spend a few hours digesting this.
您的问题很可能与 JavaFX 无关,而是与一些编码混乱有关。UTF-8(它不是一组语言,而是一种 Unicode 字符集编码)在 Java 中完全受支持。帮自己一个忙,花几个小时来消化这个。
回答by Mohamed Saad
just add ?useUnicode=true&characterEncoding=utf8
after connection url
只需?useUnicode=true&characterEncoding=utf8
在连接 url 后添加
it will be like this
会是这样
jdbc:mysql://localhost:port/dataBaseName?useUnicode=true&characterEncoding=utf8