更改文件编码 [英] change file encoding

查看:128
本文介绍了更改文件编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些HTML网页中,我有问题与字符编码。似乎问题的原因是一些.html文件不保存为UTF-8编码文件。即使我已经指示Eclipse将这些文件保存为UTF-8,当我在浏览器中打开它们时,它表示文件是ISO-8859-1。

I have a problem with character encoding in some HTML pages. It seems that the cause of the problem is that some of the .html files are not saved as UTF-8 encoded files. Even though I have instructed Eclipse to save these files as UTF-8, when I open them in a browser, it indicates that the files are ISO-8859-1.

如何将这些文件的编码更改为UTF-8?

How can I change the encoding of these files to UTF-8?

更新:我已经在每个网页的部分

UPDATE: I already have the following included in the section of each webpage

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

我正在使用Apache Web服务器。

I am using the Apache web server.

谢谢,
Donal

Thanks, Donal

推荐答案

您可能需要更改Web服务器发送客户端的内容类型标头。

You may need to change the content type header that your web server sends the client.

编辑:虽然这对于这种特殊情况有效,但是在其他情况下,使用工具来更改其他海报建议的文件编码可能是更好的解决方案。 YMMV。

While this did work for this particular situation, using a tool to change the file encoding as suggested by other posters may be a better solution in other situations. YMMV.

在Eclipse中保存为UTF-8的说明(我知道您已经拥有):

Instructions for saving as UTF-8 in Eclipse (which I realize you already have):

您应该为HTML文档更改工作空间中的默认编码。

You should probably change the Default Encoding in your workspace for the HTML document.

这是适用于Eclipse 3.4。

This is for Eclipse 3.4. If you have a different version, this may be slightly different.

转到窗口 - >首选项_b $ b在首选项窗口中转到常规 - >内容类型

此时,您可以为首选项窗口底部附近的文件指定默认编码。展开文本并选择HTML。在默认编码条目中,输入UTF-8。然后点击右侧的更新。

Goto Window->Preferences
In the Preferences window goto General->Content Types
At this point, you can specify a 'Default Encoding' for files near the bottom of the preferences window. Expand 'Text' and select HTML. In the 'Default Encoding' entry, put UTF-8. Then click 'update' at the right.

此后,所有HTML文件都应以UTF-8格式保存。

After this, all HTML files should be saved in UTF-8 format.

这篇关于更改文件编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆