本文共 2055 字,大约阅读时间需要 6 分钟。
如果经常使用Struts,并做过国际化操作的人来说,对于中文资源文件的处理应该不会感到陌生的。比如下面两个文件,一个是英文的,一个是中文的。对于英文的,一切照常;对于中文的,一般需要用JDK的native2ascii工具进行转换, application_en.properties |
# Resources for the Hello sample applicationhello.title=A first Struts programhello.prompt.user=Please enter a UserName hello.page.hello=Hellohello.page.wellocome=Wellcome to Blog of Javamxj |
application_zh_CN.properties |
# Hello实例使用的资源文件hello.title=第一个Struts应用hello.prompt.user=请输入用户名hello.page.hello=你好hello.page.wellocome=欢迎来到Javamxj的Blog |
native2ascii-本地码-至-ASCII 码转换器 |
将含有本地编码字符(既非 Latin1 又非 Unicode 字符)的文件转换为 Unicode 编码字符的文件。 结构native2ascii [options] [inputfile [outputfile]] 说明Java 编译器和其它 Java 工具只能处理含有 Latin-1 和/或 Unicode 编码(/udddd 记号)字符的文件。native2ascii 将含有其它字符编码的文件转换成含 Latin-1 和/或 Unicode 编码字符的文件。 若省略 outputfile,则使用标准输出设备输出。此外,如果也省略 inputfile,则使用标准输入设备输入。 选项-reverse 执行相反的操作:将含 Latin-1 和/或 Unicode 编码字符的文件转换成含本地编码字符的文件: -encoding encoding_name 指定转换过程使用的编码名称。缺省的编码从系统属性 file.encoding 中得到。encoding_name 字符串必须是符合要求的字符串。 |
转换后的application_zh_CN.properties |
# Hello/u5b9e/u4f8b/u4f7f/u7528/u7684/u8d44/u6e90/u6587/u4ef6 hello.title=/u7b2c/u4e00/u4e2aStruts/u5e94/u7528hello.prompt.user=/u8bf7/u8f93/u5165/u7528/u6237/u540dhello.page.hello=/u4f60/u597dhello.page.wellocome=/u6b22/u8fce/u6765/u5230Javamxj/u7684Blog |