在eclipse中配置中文字符集

来源:互联网 发布:驾校发展数据 编辑:程序博客网 时间:2024/06/07 17:54

 

操作系统:windows 2003

区域语言:日语

eclipse版本:version=3.5.0 (伽利略)

 

因为是在日文下的操作系统,所以eclipse下缺省字符编码是操作系统缺省的编码(LOCALE) :MS932

 

操作系统的字符集可以用下面的程序获得:

 

    package test;

    import java.util.Enumeration;

    import java.util.Properties;

    public class Test {

        public static void main(String[] args) {

            Properties props = System.getProperties();

            Enumeration names = props.propertyNames();

            while ( names.hasMoreElements() ) {

                String key = (String)names.nextElement();

                String value = props.getProperty(key);

                System.out.println(key+":"+value);

            }

        }

    }

 

备注:sun.io.unicode.encoding=UnicodeLittle     unicode=unicodeLittle!=UTF8!=UTF16


 

    所以需要对eclipse进行配置,方法如下: 

 

    eclipse下打开windows->preferences,左侧导航栏中general->workspace,右侧Text file encoding,default中为MS932,此时如果编写java源文件,是不支持中文字符的。选中other,然后选中UTF-8,此时才会支持中文字符。 

 

    打开windows->preferences,左侧导航栏中general->Content Types,右侧可以对java 源文件,java class file 等设置encoding 格式。

 

    打开windows->preferences,左侧导航栏中general->Editors->Text Editors->Spelling,右侧有个encoding,应该是对应文本编辑拼写的字符集。 

    打开windows->preferences,左侧导航栏中web下可以设置CSS,JSP,HTML的编码格式,不过这些可以直接在jsp,html文件中设置。

    打开windows->preferences,左侧导航栏中xml下可以设置编辑xml用的字符集。

 

    文件,右键,选择-> preferences,里面可以设置当前文件的Text file encoding。

 

        记录以备忘!!!

原创粉丝点击