1 Star 1 Fork 1

snowelf / mule

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
I18N.md 1.69 KB
一键复制 编辑 原始数据 按行查看 历史

Internationalization Guidelines

There are two levels of internationalization functionality in Mule.

  • Level 1 Core Internationalization Support Java provides basic internationalization functions in the language and bundled libraries. Mule supports message conversion by the specified encoding in metadata and configuration files.
  • Level 2 Message Catalog Mule supports a locale-based message catalog.

Encoding Priority

When writing code, respect the following priority order:

  1. encoding in metadata (HTTP headers, Mail headers, etc.)
  2. encoding in the configuration file
  3. hard-coded default encoding or platform default encoding

Byte Stream Conversion

Conversion between string and byte stream is locale-sensitive. If you write code for byte stream conversion, carefully consider the encoding you use.

The following lists typically misused APIs.

  • Incorrect: String#getBytes(). Correct: Use String#getBytes(String charsetName) if you handle non-ASCII strings.
  • Incorrect: String#String(byte[] bytes). Correct: Use String(byte[] bytes, String charsetName) if you handle non-ASCII byte stream. The following constructors are not friendly to internationalization and should be avoided.
    • String(byte ascii[], int hibyte, int offset, int count);
    • String(byte ascii[], int hibyte);
    • String(byte bytes[], int offset, int length);
  • Incorrect: InputStreamReader#InputStreamReader(InputStream in) and Friends. Correct: Use InputStreamReader(InputStream in, String charsetName) if you handle non-ASCII byte stream. If you use subclasses of Reader and Writer, use a constructor with charsetName (we consider charsetName as encoding name in this context).
Java
1
https://gitee.com/lan13217/mule.git
git@gitee.com:lan13217/mule.git
lan13217
mule
mule
3.7.2

搜索帮助