This paper illustrates the method of implementing ASC to Chinese character and Chinese character conversion asc by JavaScript. Share to everyone for your reference, specific as follows:
We often write Java programs will use the properties file, some messages and other information in the properties file, but we see are some coding.
Struts1.1b2 's example of a native resource file is encoded in Unicode, so if you want to run it, you must also encode your Applicationresources_zh in Unicode. There are two ways to do this:
① uses JDK's Native2ascii tool .
Native2ascii Function Description:
A file that converts files containing locally encoded characters (both Latin1 and non-Unicode characters) to Unicode encoded characters.
syntax : native2ascii [Options] [Inputfile [OutputFile]]
Supplemental Note : the Java compiler and other Java tools can only handle files that contain Latin-1 and/or Unicode encoding (UDDDD notation) characters. Native2ascii converts files containing other character encodings into files containing Latin-1 and/or Unicode encoded characters.
If OutputFile is omitted, the standard output device output is used.
In addition, if Inputfile is omitted, the standard input device input is used.
Command Options :
-reverse performs the opposite: converts files containing Latin-1 and/or Unicode encoded characters to files with locally encoded characters.
-encoding[encoding_name] Specifies the encoding name used by the conversion process. The default encoding is obtained from the system attribute file.encoding.
Application Example: native2ascii-encoding GBK applicationresources.properties applicationresources_zh_cn.properties
My approach:
1. Copy the applicationresource.properties of the information in English and rename it to a (to reduce the length of the DOS command);
2, use EditPlus Edit file A, write Chinese information; 3, in the DOS window, switch to file a directory, run: Native2ascii a applicationresource_zh.properties
② I used JavaScript to write a code and Chinese characters to turn the tool . For reference only.
<! Doctypehtmlpublic "-//w3c//dtdhtml4.0transitional//en" > <HTML> <HEAD> <TITLE> asc←→nativeツール@ Hangzhou Wang Yufeng </TITLE> <metaname= "generator" content= "EditPlus" > <metaname= "Author" content= "Szwangdf@163.com" > <metaname= "Keywords" content= "asc←→nativeツール" > <metaname= "Description" content= "
asc←→nativeツール "> <script language=" javascript > Function Native2ascii () {var regexp=/[^/x00-/xff]/g;
var N=document.getelementbyid ("native"). Value;
var a=n;
while (M=regexp.exec (n)) {a=a.split (m[0]). Join (Escape (m[0)). Split ("%"). Join ("/"));
} document.getElementById ("ASCII"). Value=a;
function ascii2native () {var A=document.getelementbyid ("ASCII"). Value;
var n=a;
var n=unescape (N.split ("/"). Join ("%"));
document.getElementById ("native"). Value=n; } </script> </HEAD> <BODY>
I hope this article will help you with your JavaScript programming.