myeclipse字符编码

来源:互联网 发布:土地整理预算软件 编辑:程序博客网 时间:2024/04/25 16:01
<pre id="question-content" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; zoom: 1;"><span style="background-color: rgb(252, 254, 252); font-family: Arial; line-height: 24px;"><strong>问题:这10种设置字符编码的区别与作用域(作用域:所有空间、当前工作空间、当前工程、当前文件)</strong></span><pre id="best-answer-content" class="reply-text mb10" name="code" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 10px; padding: 0px; zoom: 1;"><span style="background-color: rgb(255, 255, 255);"><strong>1、</strong></span><span style="background-color: rgb(255, 252, 246);"><strong>Window->Preferences->General->Content Types-></strong>比如选中右边的JSP,窗口下面则出现Default encoding,在右边修改该文件默认的编码方式,update即可(图一)————<strong><span style="color: rgb(255, 0, 0);">修改一类文件的编码方式</span></strong></span>
2、Window->Preferences->General->Editors->Text Editors->Spelling(图二)
<span style="background-color: rgb(255, 252, 246);"><strong>3、Window->Preferences->General->Workspace(图三)————<span style="color: rgb(255, 0, 0);">修改工作空间的编码方式</span></strong></span><pre id="best-answer-content" class="reply-text mb10" name="code" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 10px; padding: 0px; zoom: 1;"><span style="background-color: rgb(255, 252, 246);"><strong>4、Window->Preferences->Myeclipse Enterprise Workbench->Files and Editors(图四)</strong></span><span style="background-color: rgb(255, 252, 246);"><strong>5、</strong></span><span style="background-color: rgb(255, 252, 246);"><strong>Window->Preferences->SQL Development->Execution Plan View Options(图五)</strong></span><pre id="best-answer-content" class="reply-text mb10" name="code" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 10px; background-color: rgb(255, 255, 255); padding: 0px; zoom: 1;"><span style="background-color: rgb(255, 252, 246);"><strong>6、Window->Preferences->SQL Development->SQL Results View Options->Export Format Options(图五)</strong></span><span style="background-color: rgb(255, 252, 246);"><strong>7、Window->Preferences->Web and XML->CSS Files(图六)</strong></span><pre id="best-answer-content" class="reply-text mb10" name="code" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 10px; background-color: rgb(255, 255, 255); padding: 0px; zoom: 1;"><pre id="best-answer-content" class="reply-text mb10" name="code" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 10px; background-color: rgb(255, 255, 255); padding: 0px; zoom: 1;"><span style="background-color: rgb(255, 252, 246);"><strong>8、Window->Preferences->Web and XML->HTML Files(图六)</strong></span><span style="background-color: rgb(255, 252, 246);"><strong>9、Window->Preferences->Web and XML->JSP Files(图六)</strong></span><pre id="best-answer-content" class="reply-text mb10" name="code" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 10px; background-color: rgb(255, 255, 255); padding: 0px; zoom: 1;">
<span style="background-color: rgb(255, 255, 51);"><strong>10、改变项目的编码方式</strong></span><span style="background-color: rgb(255, 252, 246);"><strong>:右键单击项目名称->Properties->Resource->Text file encoding</strong> (图七)————<span style="color: rgb(255, 0, 0);"><strong>修改单个工程的编码方式;若右键单击一个文件,则修改单个文件的编码方式</strong></span></span>
<pre id="question-content" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; zoom: 1;"><span style="font-family: Arial;"><span style="line-height: 24px;"><img src="http://my.csdn.net/uploads/201206/28/1340874128_5064.jpg" alt="" style="border: none; max-width: 100%; background-color: rgb(255, 252, 246);" /></span></span><span style="background-color: rgb(252, 254, 252);">==================================================================================================================================</span><pre id="question-content" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; zoom: 1;"><span style="background-color: rgb(252, 254, 252);">==================================================================================================================================</span>
<p align="left" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px;"><span style="background-color: rgb(255, 255, 51);">eclipse出现乱码原因:</span><span style="background-color: rgb(255, 255, 255);">因为eclipse编辑器选择的编码规则是可变的。一般默认都是UTF-8或者GBK,当从外部导入的一个工程时,如果该工程的编码方式与eclipse中设置的编码方式不同,就会产生中文的乱码问题,这其中还有几种情况:① 如果 <span style="color: rgb(0, 0, 153);">导入的整个工程的编码方式 </span>与 <span style="color: rgb(0, 0, 153);">eclipse的编码方式 </span>有冲突,那么 <span style="color: rgb(0, 0, 153);">这个工程里所有的中文 </span>都是乱码;② 如果 <span style="color: rgb(0, 0, 153);">所有工程的编码方式 </span>与 <span style="color: rgb(0, 0, 153);">eclipse工作空间的编码方式 </span>有冲突,那么 <span style="color: rgb(0, 0, 153);">所有的工程里的中文 </span>都有可能是乱码。③ 对于<span style="color: rgb(0, 0, 153);">eclipse工作空间</span>,eclipse会把你改的设置保存在<span style="color: rgb(0, 0, 153);">工作空间的设置文件</span>中;④ 对于<span style="color: rgb(0, 0, 153);">单个工程的编码方式</span>进行修改,那么eclipse会把编码方式保存在<span style="color: rgb(0, 0, 153);">该工程的.setting文件包</span>里。</span></p><p align="left" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px;"><span style="background-color: rgb(255, 255, 51);">避免中文乱码问题两个原则:</span></p><p align="left" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">(1)避免频繁更换工作空间,最好项目<span style="color: rgb(0, 0, 153);">从一开始就在一个工作空间</span>中进行,并且最好设置工作空间的编码方式为<span style="color: rgb(0, 0, 153);">你平时最经常使用的</span>或者是<span style="color: rgb(0, 0, 153);">公司规定的项目编码方式</span>,这样工程就会使用<span style="color: rgb(0, 0, 153);">工作空间的编码方式</span>,避免出现编码不一致的情形;</span></p><p align="left" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px;"><span style="background-color: rgb(255, 255, 255);">(2)相同类型的文件尽量使用相同的编码方式,可以保证相同类型的文件都能使用一致的编码设置;</span></p><span style="background-color: rgb(255, 255, 51);"></span><span style="background-color: rgb(255, 255, 51);"><span style="font-family: Arial;"><strong><span style="line-height: 22px;">导入项目产生乱码的解决方案之一</span></strong></span></span><span style="background-color: rgb(255, 252, 246);"><span style="font-family: Arial;"><span style="line-height: 22px;">:</span></span></span><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px;">①将整个project设置编码UTF-8(UTF-8可以最大的支持国际化)</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px;">windows->Preferences->general->Workspace->Text file encoding->Other框中的Text file encoding改为UTF-8。②对java源文件编码设置为UTF-8.</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px;">windows->Preferences->general->Context Types->Text,选择Java Source File,在下面的Default encoding输入框中输入UTF-8,点Update,则设置Java文件编码为UTF-8。③如果没有及时反映,尝试重启Myeclipse</p><div></div>
                                             
0 0
原创粉丝点击