zend studio html乱码,解决Eclipse/Zend Studio编辑xml/html乱码问题

当Eclipse/ZendStudio中PHP项目设置为UTF-8编码,但HTML文件仍显示为GBK乱码时,问题在于HTML文件的编码判定优先级。通过Windows->Preferences->General->ContentTypes,将text/html的DefaultEncoding设置为UTF-8即可解决。此方法适用于遇到IDE自动检测编码不正确的情况。
摘要由CSDN通过智能技术生成

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内有

的定义,就按照charset的来设置编码。

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

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

5922fd1cdf69f4b52aa2fca769285ce6.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值