zoukankan      html  css  js  c++  java
  • [转]解决Eclipse/Zend Studio编辑xml/html乱码问题

    非常感谢作者kindlymouse,这个问题困扰了我好长时间,终于解决了,在此表示感谢,同时转载到博客作为学习笔记。
    转自:http://blog.csdn.net/kindlymouse/article/details/6939931 


    Eclipse/Zend Studio编辑一php项目,已经设置了项目的Text file Encoding为UTF-8,发现打开php文件显示中文正常,但某些html打开显示为乱码。右键查看这些html的properties,resource中的Text File Encoding显示为:Default(determined from content:GBK)。原来项目设置的编码对这些文件不起作用。

    该问题查看Eclipse帮助文档,在“Defining HTML file preferences"一节中有如下解释:

    Note: Encoding detection (when loading files) is performed in the following order:

    • Locate the encoding name embedded in the document.
    • When no encoding is embedded in the document, an automaticencoding detector attempts to determineencoding used in the document.
    • If the encoding still cannot bedetermined, theencoding defined in the Encoding field is used.

    也就是HTML文件的编码判定顺序,按照文件内容编码优先,然后是文件编码。也就是说,如果HTML内有<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    的定义,就按照charset的来设置编码。

    问题是,我打开的html均没有设置charset,但是默认还是认为是gbk文件。发现是contentType设置问题。想取消IDE自身的determined机制,可惜Eclipse还不能设置。几经折腾,最后采用如下办法解决问题:

    windows->preferences->General->Content Types,选择text->html,在最下面的Default encoding中,设置为utf-8,点击update,问题解决。

     

  • 相关阅读:
    求求你,快去学习吧!!
    研究生英语读写译----topic3
    SQL----where 和 on 的区别
    SQL----语句执行顺序
    SQL----Inner Join、 Outer Join、Cross Join理解
    将一般的数值转换为金额格式(分隔千分位和自动增加小数点)
    伪元素 before 和 after 各种妙用
    抽空笑一笑
    别笑抽咯
    JavaScript继承方式详解
  • 原文地址:https://www.cnblogs.com/greatwang/p/2648249.html
Copyright © 2011-2022 走看看