2

我在 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,但是当我在浏览器中保存和查看文件时,我的井号已更改为 £。

我可以通过添加来解决问题

<cfprocessingdirective pageencoding = "utf-8"/>

到我的 CFM 文件的顶部,但对于我正在处理的网站,我实际上无法为每个页面都这样做,我尝试将它添加到页面标题包含但那不起作用。

如果我将文件保存为 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
4

3 回答 3

1

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.

于 2011-10-06T11:26:52.450 回答
0
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 中是否有这样的东西(有一段时间没有使用它)?

于 2011-10-06T10:24:58.627 回答
-1

试着放

<cfprocessingdirective pageencoding="utf-8" />

靠近 Application.cfc 的顶部

于 2011-10-06T10:03:50.483 回答