Aptana 3 - CFEclipse - .cfm 文件 - UTF-8 编码不正确

发布于 2024-12-08 08:48:39 字数 1743 浏览 0 评论 0原文

我在 Aptana 3 中使用 CFEclipse 的 CFML 编辑器创建了以下 .cfm 文件:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>templates</title>

</head>

<body>
£
</body>
</html>

我的工作区编码设置为 UTF-8,但是当我在浏览器中保存并查看该文件时,我的井号已更改为 £。

我可以通过添加到 CFM 文件的顶部来解决问题

<cfprocessingdirective pageencoding = "utf-8"/>

,但对于我正在处理的网站,我实际上无法对每个页面都执行此操作,并且我尝试将其添加到页眉包含中,但这不起作用。

如果我将文件保存为 HTML 文件或使用记事本 utf-8 保存文件,井号就可以,所以它似乎与 Aptana 中 CFEclipse 插件的 CFML 编辑器有关。有没有人以前遇到过这个问题或者对如何解决它有任何想法?

谢谢

编辑(添加字符集标题):

HTTP/1.1 200 OK
Date: Thu, 06 Oct 2011 13:26:11 GMT
Server: Apache/2.2.17 (Win32) PHP/5.3.4 JRun/4.0
Set-Cookie: CFGLOBALS=urltoken%3DCFID%23%3D12703%26CFTOKEN%23%3D40776140%23lastvisit%3D%7Bts%20%272011%2D10%2D06%2014%3A26%3A11%27%7D%23timecreated%3D%7Bts%20%272011%2D10%2D04%2017%3A05%3A01%27%7D%23hitcount%3D314%23cftoken%3D40776140%23cfid%3D12703%23;expires=Sat, 28-Sep-2041 13:26:11     GMT;path=/
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

GET /enc_test3.cfm HTTP/1.1
Host: www.foo.co.uk
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: keep-alive

I have created the following .cfm file using the CFML editor of CFEclipse in Aptana 3:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>templates</title>

</head>

<body>
£
</body>
</html>

My Workspace encoding is set to UTF-8, but when I save and view the file in a browser my pound sign has changed to £.

I can resolve the problem by adding

<cfprocessingdirective pageencoding = "utf-8"/>

to the top of my CFM file but for the website I am working on I can't realisticly do that for every page and I've tried adding it to the page header include but that doesn't work.

If I save the file as HTML file or save the file using notepad utf-8 the pound sign is fine, so it seems to be related to the CFML editor of the CFEclipse plugin in Aptana. Has anyone come across this issue before or have any ideas on how to resolve it?

Thanks

EDIT (Added charset headers) :

HTTP/1.1 200 OK
Date: Thu, 06 Oct 2011 13:26:11 GMT
Server: Apache/2.2.17 (Win32) PHP/5.3.4 JRun/4.0
Set-Cookie: CFGLOBALS=urltoken%3DCFID%23%3D12703%26CFTOKEN%23%3D40776140%23lastvisit%3D%7Bts%20%272011%2D10%2D06%2014%3A26%3A11%27%7D%23timecreated%3D%7Bts%20%272011%2D10%2D04%2017%3A05%3A01%27%7D%23hitcount%3D314%23cftoken%3D40776140%23cfid%3D12703%23;expires=Sat, 28-Sep-2041 13:26:11     GMT;path=/
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

GET /enc_test3.cfm HTTP/1.1
Host: www.foo.co.uk
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: keep-alive

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

彡翼 2024-12-15 08:48:39

你别无选择。如果您的 CFM 文件中有 UTF-8(或者基本上任何“非 ASCII”~)内容,您需要告诉 CF 编译器该文件是如何编码的(使用 CFPROCESSINGDIRECTIVE,就像您所做的那样)。

由于这需要在编译时完成,因此无法通过在 Application.cfc 或任何“上游”CFM 文件中放置标记来工作,因为“非流化”是在运行时而不是编译时确定的。

总的来说,CFM 文件中很少有非 ASCII 文本,因为 CFM 应该是代码,而不是内容或数据。也就是说,我意识到这并不总是可能的。

You have no choice. If you have UTF-8 (or, basically, any "non-ASCII" ~) content in your CFM files, you need to tell the CF compiler how the file is encoded (with CFPROCESSINGDIRECTIVE, as you have done).

As this needs to be done at compile time, it cannot work by putting a tag in your Application.cfc or any "upstream" CFM file, because the "unstreamedness" is determined at runtime, not compile time.

On the whole, it should be a rarety that you have non-ASCII text in a CFM file because a CFM should be pretty much code, not content or data. That said, I realise this is not always possible.

陌路黄昏 2024-12-15 08:48:39
My Workspace encoding is set to UTF-8, but when I save and view the file in a browser my pound sign has changed to £. 

显然,您打包的 .cfm 文件并不是真正的 UTF8。 CFEclipse不处理文件编码,至少我还没有看到这样的设置。但是Eclipse能够为每个资源(文件/属性)定义编码,Aptana中有这样的东西吗(有一段时间没有使用它了)?

My Workspace encoding is set to UTF-8, but when I save and view the file in a browser my pound sign has changed to £. 

Obviously, your crated .cfm files are not really UTF8. CFEclipse does not handle file encoding, at least I haven't seen such settings for it. But Eclipse has ability to define encoding per resourse (File/Properties), is there such thing in Aptana (haven't used it for a while)?

下雨或天晴 2024-12-15 08:48:39

尝试将其放在

<cfprocessingdirective pageencoding="utf-8" />

Application.cfc 的顶部附近

Try putting

<cfprocessingdirective pageencoding="utf-8" />

near the top of your Application.cfc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文