看了网上的很多的解决方法似乎都很好但实际的操作中还是发现了很多的问题 试了很久才找到最终的解决方案
主要是属性文件的字符转换问题具体步骤和检测如下:
) 用一般的编辑器输入所要显示的汉字
) 使用Java JDK 下的nativeascii 详细说明见
nativeascii NativetoASCII Converter
Converts a file with nativeencoded characters (characters which are nonLatin and nonUnicode) to one with Unicodeencoded characters
SYNOPSIS
nativeascii [options] [inputfile [outputfile]]
DESCRIPTION
The Java compiler and other Java tools can only process files which contain Latin and/or Unicodeencoded (\udddd notation) characters nativeascii converts files which contain other character encodings into files containing Latin and/or Unicodeencoded charaters
If outputfile is omitted standard output is used for output If in addition inputfile is omitted standard input is used for input
OPTIONS
reverse
Perform the reverse operation: convert a file with Latin and/or Unicode encoded characters to one with nativeencoded characters
encoding encoding_name
Specify the encoding name which is used by the conversion procedure The default encoding is taken from System property fileencoding The encoding_name string must be taken from the first column of the table of supported encodings in the Supported Encodings document
Joption
Pass option to the Java virtual machine where option is one of the options described on the reference page for the java application launcher For example JXmsm sets the startup memory to megabytes
For encoding name you can reference:
For chinese use normally use: GBK Big In Suns encoding document it is mentioned this conversion need: lib/rtjar or lib/charsetsjar These two file only can file Suns JRE package They cant find in Suns JDK package
但是我在转换的时候没有这两个文件似乎也没有问题
Example: nativeascii encoding GBK Inputfilename outputfilename
转换后的校验
nativeascii 会因为你的系统不同可能会有不同的转换结果 如果发现问题你可以去:
查询依据目前的版本你可以找到
East Asian Scripts> Han ideographs>Unified CJK ideographs(M)
这个文件
下载后你用PDF reader 的search功能找到你要转换的汉字比较转换后的
字符是否正确比如我在转换后为 /u
所有的JSP文件采用UTF格式遍写并在文件头强制:
<%@ page contentType=text/html;charset=UTF language=java %>
这样你的问题就解决了