• <i id='M4lk9'><tr id='M4lk9'><dt id='M4lk9'><q id='M4lk9'><span id='M4lk9'><b id='M4lk9'><form id='M4lk9'><ins id='M4lk9'></ins><ul id='M4lk9'></ul><sub id='M4lk9'></sub></form><legend id='M4lk9'></legend><bdo id='M4lk9'><pre id='M4lk9'><center id='M4lk9'></center></pre></bdo></b><th id='M4lk9'></th></span></q></dt></tr></i><div id='M4lk9'><tfoot id='M4lk9'></tfoot><dl id='M4lk9'><fieldset id='M4lk9'></fieldset></dl></div>

        <small id='M4lk9'></small><noframes id='M4lk9'>

        • <bdo id='M4lk9'></bdo><ul id='M4lk9'></ul>
      1. <legend id='M4lk9'><style id='M4lk9'><dir id='M4lk9'><q id='M4lk9'></q></dir></style></legend>

        <tfoot id='M4lk9'></tfoot>
      2. 如何在 Java 应用程序中处理多种语言?

        时间:2024-08-25
          <tbody id='8pRYu'></tbody>
            • <small id='8pRYu'></small><noframes id='8pRYu'>

              <tfoot id='8pRYu'></tfoot>
              <i id='8pRYu'><tr id='8pRYu'><dt id='8pRYu'><q id='8pRYu'><span id='8pRYu'><b id='8pRYu'><form id='8pRYu'><ins id='8pRYu'></ins><ul id='8pRYu'></ul><sub id='8pRYu'></sub></form><legend id='8pRYu'></legend><bdo id='8pRYu'><pre id='8pRYu'><center id='8pRYu'></center></pre></bdo></b><th id='8pRYu'></th></span></q></dt></tr></i><div id='8pRYu'><tfoot id='8pRYu'></tfoot><dl id='8pRYu'><fieldset id='8pRYu'></fieldset></dl></div>
              • <bdo id='8pRYu'></bdo><ul id='8pRYu'></ul>
              • <legend id='8pRYu'><style id='8pRYu'><dir id='8pRYu'><q id='8pRYu'></q></dir></style></legend>

                  本文介绍了如何在 Java 应用程序中处理多种语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在编写一个使用 JSP 和 Java 的程序.如何使用属性文件来支持多种语言?

                  I am writing a program use JSP and Java. How can I use property files to support multiple languages?

                  顺便说一句,总有一些像 u4345 这样的东西.
                  这是什么?他们是怎么来的?

                  And by the way, there are always some things like u4345.
                  What is this? How do they come?

                  推荐答案

                  对于多种语言,请查看 ResourceBundle 类.

                  For the multiple languages, check out the ResourceBundle class.

                  关于 u4345,这是 Java 的黑暗和非常烦人的遗留角落之一.属性文件需要是 ASCII 格式,因此所有非 ASCII 字符都需要编码为 uxxxx(它们的 Unicode 值).您可以使用 native2ascii 命令转换文件以使用此编码线工具.如果您使用的是 IDE 或构建工具,则应该有一个自动调用它的选项.

                  About the u4345, this is one of the dark and very annoying legacy corners of Java. The property files need to be in ASCII, so that all non-ASCII characters need to encoded as uxxxx (their Unicode value). You can convert a file to use this encoding with the native2ascii command line tool. If you are using an IDE or a build tool, there should be an option to invoke this automatically.

                  如果属性文件是你自己可以完全控制的,你可以从 Java6 开始,也可以直接在属性文件中使用 UTF-8(或任何其他字符集),并且 在加载时指定编码:

                  If the property file is something you have full control over yourself, you can starting from Java6 also use UTF-8 (or any other character set) directly in the property file, and specify that encoding when you load it:

                  // new in Java6
                  props.load(new InputStreamReader(new FileInputStream(file), 'UTF-8'));
                  

                  同样,这仅在您自己加载属性时才有效,而不是在其他人加载时才有效,例如 ResourceBundle(用于国际化).

                  Again, this only works if you load the Properties yourself, not if someone else does it, such as a ResourceBundle (used for internationalization).

                  这篇关于如何在 Java 应用程序中处理多种语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:将 Java Swing 桌面应用程序国际化的最佳实践是什么? 下一篇:在 Java 中,我如何找出我的资源包可用的语言

                  相关文章

                  <small id='c7XAH'></small><noframes id='c7XAH'>

                  • <bdo id='c7XAH'></bdo><ul id='c7XAH'></ul>

                    <i id='c7XAH'><tr id='c7XAH'><dt id='c7XAH'><q id='c7XAH'><span id='c7XAH'><b id='c7XAH'><form id='c7XAH'><ins id='c7XAH'></ins><ul id='c7XAH'></ul><sub id='c7XAH'></sub></form><legend id='c7XAH'></legend><bdo id='c7XAH'><pre id='c7XAH'><center id='c7XAH'></center></pre></bdo></b><th id='c7XAH'></th></span></q></dt></tr></i><div id='c7XAH'><tfoot id='c7XAH'></tfoot><dl id='c7XAH'><fieldset id='c7XAH'></fieldset></dl></div>
                    <tfoot id='c7XAH'></tfoot>

                      <legend id='c7XAH'><style id='c7XAH'><dir id='c7XAH'><q id='c7XAH'></q></dir></style></legend>