之前在很多地方都能见到I18N,特别是open source里面。
I18N就是Internationalization的缩写,其原因是I和n之间一共有18个字母(寒~)。
下面这些地方会需要I18N
- Displaying characters for the users' native languages.
- Inputing characters for the users' native languages.
- Handling files written in popular encodings that are used for the users' native languages.
- Using characters from the users' native languages for file names and other items.
- Printing out characters from the users' native languages.
- Displaying messages by the program in the users' native languages.
- Formatting input and output of numbers, dates, money, etc., in a way that obeys customs of the users' native cultures.
- Classifying and sorting characters, in a way that obey customs of the users' native cultures.
- Using typesetting and hyphenation rules appropriate for the users' native languages.
当然除了I18N还有L10N(localization) 和M17N (multilingualization),这3个之间有什么区别呢,举例说明。
L10N支持2种语言,英文和另外一种语言(例如中文);
I18N支持多种语言,但是同一时间只能是英文和一种选定的语言,例如英文+中文、英文+德文、英文+韩文等等;
M17N可以在同一时间支持多种语言,例如你可以在一个页面里看到中文、英文、德文和韩文。
人们常把I18N作为“国际化”的简称,其来源是英文单词 internationalization的首末字符i和n之间的字符数为18。
随着全球经济一体化成为一种主流趋势,软件开发者应该开发出支持多国语言、国际化的Web应用。对于Web应用够说,同样的布面在不同的语言的环境下需要显示不同的效果。也就是说,一个Web应用程序在运行时能够根据客房端请求所来自的国家和语言的不同显示和不同的用户界面。这样 ,当需要在应用程序中添加对一种新的语言的支持时,不需要对已有的软件返工,无需修改应用程序的程序代码。
事实上,准备资源包的过程,就是把对应不同语言的用户所涉及的文本和图片保存在多个文本文件中,客户端根据不同的环境需要进行更换。这些文件被称为“属性文件”,所有属性文件合在一起被称为资源包(Resource Bundle)。
native2ascii是sun java sdk提供的一个工具。用来将别的文本类文件(比如*.txt,*.ini,*.properties,*.java等等)编码转为Unicode编码。为什么要进行转码,原因在于程序的国际化。Unicode编码的定义:Unicode(统一码、万国码、单一码)是一种在计算机上使用的字符编码。它为每种语言中的每个字符设定了统一并且唯一的二进制编码,以满足跨语言、跨平台进行文本转换、处理的要求。1990年开始研发,1994年正式公布。随着计算机工作能力的增强,Unicode也在面世以来的十多年里得到普及。
native2ascii的使用方法如下:
native2ascii -[options] [inputfile [outputfile]]
-[options]:表示命令开关,有两个选项可供选择
-reverse:将Unicode编码转为本地或者指定编码,不指定编码情况下,将转为本地编码。
-encoding encoding_name:转换为指定编码,encoding_name为编码名称。
[inputfile [outputfile]]
inputfile:表示输入文件全名。
outputfile:输出文件名。如果缺少此参数,将输出到控制台。
例如:
native2ascii test.txt test.xml
可以使用该命令的“-encoding” 参数,将文档转换为指定的编码格式。如
native2ascii -encoding GB2312 test.xml
还可以使用native2ascii的“-reverse”参数,将Unicode编码格式文件恢复为指定编码格式文件。如
native2ascii -encoding GB2312 -reverse test.xml test.txt
其它一些网上的例子:
A:将zh.txt转换为Unicode编码,输出文件到u.txt
native2ascii zh.txt u.txt
打开u.txt,内容为“\u7194\u5ca9”。
B:将zh.txt转换为Unicode编码,输出到控制台
C:\test>native2ascii zh.txt
\u7194\u5ca9
可以看到,控制台输出了“\u7194\u5ca9”。
C:将zh.txt转换为ISO8859-1编码,输出文件到i.txt
native2ascii -encoding ISO8859-1 zh.txt i.txt
打开i.txt文件,内容为“\u00c8\u00db\u00d1\u00d2”。
D:将u.txt转换为本地编码,输出到文件u_nv.txt
native2ascii -reverse u.txt u_nv.txt
打开u_nv.txt文件,内容为“熔岩”。
E:将u.txt转换为本地编码,输出到控制台
C:\test>native2ascii -reverse u.txt
熔岩
可以看到,控制台输出了“熔岩”。
F:将i.txt转换为本地编码,输出到i_nv.txt
native2ascii -reverse i.txt i_nv.txt
打开i_nv.txt文件,内容为“\u00c8\u00db\u00d1\u00d2”。发现转码前后完全一样的。也就是说,等于没有转,或者说思想糊涂,对命名没有理解。
G:将i.txt转换为GBK编码,输出到i_gbk.txt
native2ascii -reverse -encoding GBK i.txt i_gbk.txt
打开i_gbk.txt文件,内容为“\u00c8\u00db\u00d1\u00d2”。发现转码前后完全一样的。也就是说,等于没有转,或者说思想糊涂,对命名没有理解。
H:将u_nv.txt转码到本地编码GBK,输出到控制台
C:\test>native2ascii -reverse -encoding ISO8859-1 i.txt
熔岩
从这个结果看,目标达到到了,编码i.txt为ISO8859-1,转为本地编码后内容为“熔岩”。从这里应该意识到,native2ascii -reverse命令中-encoding指定的编码为源文件的编码格式。而在native2ascii 命令中-encoding指定的编码为(生成的)目标文件的编码格式。这一点非常的重要!切记!!
继续探索,新建文件12a.txt,内容“12axyz”。看看纯字母数字的编码又如何。
I:将纯字母数字的文本文件12a.txt转换为Unicode编码
native2ascii 12a.txt 12a_nv.txt
打开12a_nv.txt文件,内容为“12axyz”。
继续测试,转为ISO8859-1编码看看
native2ascii 12a.txt 12a_nv.txt
打开12a_nv.txt文件,内容为“12axyz”。
继续测试,转为ISO8859-1编码看看
C:\test>native2ascii -encoding ISO8859-1 12a.txt
12axyz
结果还是没有转码。从结果可以得出结论:对于纯数字和字母的文本类型文件(只有ASCII码),转码前后的内容是一样的。
分享到:
相关推荐
native2ascii简介native2ascii简介native2ascii简介native2ascii简介
native2ascii工具,不需要在命令行的转换了
Native2Ascii(Ascii2Native) Native2Ascii(Ascii2Native)
使用native2ascii进行编码格式转换 将CN.properties国际化资源文件 转换为 简体中文 控制台命令: native2ascii -reverse -encoding gbk CN.properties CN2.properties
基于JDK的native2ascii的编码转换图形工具
通过在线native2ascii转换而成的html可以在本地直接使用,将需要的转换成unicode
2、将附件下的native2ascii.link 文件放在\Eclipse6.0.1\eclipse\links目录下,然后配置path=D:\\Program Files\\Eclipse6.0.1\\eclipse\\plugins\\native2ascii 即1所放置的native2ascii 文件夹位置,根据实际路径...
native2ascii图形界面工具,简单易用
native2ascii资源文件编码转换命令
native2ascii.exe java的转码工具,需要java.dll动态库和相关程序才能执行.
native2ascii使用参考
npm install react-native-i18n 2.在app下创建如下目录 3.各文件下的内容 i18n/index.js import I18n from 'react-native-i18n'; import en from './message/en'; import zh from './message/zh'; //初始化语言 ...
用java写的中文字符转unicode码程序,功能类似于JDK里面的native2ascii,但是是图形界面,非常好用。
偶没有装JDK,所以也无法使用JDK自带的实用工具native2ascii.exe,这是一个仿制工具,仅供JAVA加载资源文件时将汉字转换为UNICODE编码用;
把文字编码变成统一的Unicode编码工具 Native Ascii 编码 本地 Java
如果您使用的是React-Native> = 0.29,只需使用命令react-native link react-native-i18n该库react-native link react-native-i18n 。 如果您使用阵营本地<0.29,安装用命令npm install -g rnpm ,然后
mytest native2ascii javamytest native2ascii javamytest native2ascii java
博文链接:https://hepeng1688.iteye.com/blog/139941
用C#编写的Native和Ascii转换工具,这只是用几分钟写的初版. "设置"按钮还没有想好添加什么功能. 目前程序是置顶的,窗体大小可以改变. 现在只有文本框内容转换,后续会添加文件转换和批量文件转换. 有什么建议可以写在...