gpt4 book ai didi

eclipse - 为什么 JSF 属性文件在 Eclipse 中不接受非 ASCII 字符?

转载 作者:行者123 更新时间:2023-12-01 04:19:00 26 4
gpt4 key购买 nike

我想知道,为什么 JSF 属性文件在 Eclipse 中不接受非 ASCII 字符?

我有一些名为“messages.properties”的属性文件,我必须为非 ASCII 字符编写 unicode 转义字符,例如:

title=\u01af\u0020\u0a3f0
header=\u0ff0\u0020\u0ab1

这意味着客户无法使用常规文本编辑器编辑这些属性文件。

有什么解决办法吗?

最佳答案

这是因为 java.util.Properties.load(InputStream) 使用 ISO-8859-1。

The load(InputStream) / store(OutputStream, String) methods work the same way as the load(Reader)/store(Writer, String) pair, except the input/output stream is encoded in ISO 8859-1 character encoding. Characters that cannot be directly represented in this encoding can be written using Unicode escapes ; only a single 'u' character is allowed in an escape sequence. The native2ascii tool can be used to convert property files to and from other character encodings.



多年来一直是一个问题。我已经通过实现进行编码转换的自定义标签用 struts 解决了这个问题,但这通常很痛苦。

Java 6 引入了 Properties.load(Writer) ,它适用于 UTF-8,但似乎还没有被广泛采用。

我建议使用 AnyEdit tools与 unicode 符号相互转换。

至于最终用户 - 如果他们要编辑属性文件(这听起来很奇怪),那么您可以让他们输入他们喜欢的任何字符,然后使用 native2acii(或它的包装器)转换文件

关于eclipse - 为什么 JSF 属性文件在 Eclipse 中不接受非 ASCII 字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2601989/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com