强制 Eclipse 忽略字符编码属性
我正在使用一个在 html 模板中使用动态字符编码的 Web 框架,如下所示:
<meta charset="${_response_encoding}">
问题是当我尝试在 Eclipse 中编辑此文件时,Eclipse 认为这是文字编码类型,因此拒绝打开文件,说:
“不支持的字符编码” 字符编码 此平台不支持“${_response_encoding}”。
有没有什么方法可以告诉 Eclipse 停止尝试变得“聪明”(因为它显然不是)而只是向我显示文本?我尝试过使用“打开方式...文本编辑器”,但结果仍然相同。
I'm working with a web framework that uses a dynamic character encoding in its html templates, like this:
<meta charset="${_response_encoding}">
The problem is when I try to edit this file in Eclipse, Eclipse thinks this is a literal encoding type, and thus refuses to open the file, saying:
"Unsupported Character Encoding" Character encoding
"${_response_encoding}" is not supported by this platform.
Is there any way to tell Eclipse to stop trying to be "smart" (because it plainly isn't) and just show me the text? I've tried using "Open With... Text Editor" but still same result.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
更改 HTML 文件的内容类型:
转至 Windows ->偏好->一般->内容类型并更改您需要的所有文件扩展名的编码(将它们设置为 utf-8)。
Change the content type for HTML files:
Go to Windows -> preferences -> General -> Content types and change encoding (set them to utf-8) for all the file extensions you need.
选择“其他”,然后选择 UTF-8。然后你的模板将正常渲染。
Choose "Other" and then select UTF-8. Then your template will render as normal.
我遇到了类似的问题,除了在更改字符编码后尝试保存文档时收到错误消息。在输入非标准
charset
值之前,我通过在 Eclipse 中执行以下操作解决了该问题:charset
值更改为您想要的非标准值。此后,该文件应该仍然可用,同时仍然具有非标准
charset
值。I had a similar problem, except I was receiving the error message when trying to save the document after changing the character encoding. I resolved the problem by doing the following in Eclipse before putting in the non-standard
charset
value:charset
value to the non-standard value you want.After this, the file should still be usable while still having the non-standard
charset
value.如果您让 Eclipse 将其视为 HTML 文件,那么它很聪明。这不是一个有效的编码名称。您是否尝试过仅模板化整个元标记?
If you're having Eclipse treat it like an HTML file, it is being smart. That's not a valid encoding name. Have you tried just templating the entire meta tag?
(如评论中所述)在 Eclipse Indigo 中,打开文件时,您会看到“不支持的字符编码”消息以及“设置编码”按钮。使用该按钮来设置 UTF-8 编码。 Eclipse 不会更改 HTML 文件中的变量。
确实,这是在逐个文件的基础上完成的,但是,在我的项目中,我为每个屏幕导入相同的元头文件。实际上,我只有两个文件需要设置(已登录的文件和未登录的文件)。
(as mentioned in a comment) In Eclipse Indigo, when opening the file you see the Unsupported character encoding message along with a Set Encoding button. Us that button to set the UTF-8 encoding. Eclipse does not change the variable in the HTML file.
True, this is done on a file-by-file basis, however, in my project I import the same meta header file for every screen. Actually, I have only two files to setup (those that are logged in and those that are not).