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

问题描述

让我先说我的最终目标(以防我的任何假设或对字符编码的理解不正确):我希望我的网页字符能够正确显示,即使我粘贴了来自Word 或其他程序.

Let me start out by saying my end goal (in case I'm incorrect in any of my assumptions or understanding of character encoding): I want the characters of my webpages to display correctly, even if I paste in unique characters from Word or other programs.

希望这可以在大多数情况下工作,而不必通过服务器端的某些编码功能来传递它.我一直在使用美国英语并从 Word 粘贴,所以看起来应该没有那么难.

Hopefully this can work most times without having to pass it through some encoding function on the server-side. I'm always working with US English and pasting from Word, so it doesn't seem like it should be that difficult.

在我看来,ColdFusion 正在弄乱我的字符编码并将撇号(可能是从 Word 粘贴的)显示为.".我的页面作为 .htm 文件工作,但是一旦我将扩展名重命名为 .cfm,它就不会.请看这里:

It seems to me that ColdFusion is messing up my character encoding and displaying apostrophe's (probably pasted from Word) as ’. My page works as a .htm file, but as soon as I rename extension to .cfm, it doesn't. See here:

以下是我所看到的,以防您有任何不同:http://i.imgur.com/tA4p1yc.png(看起来有效的说 Content-Type 是 text/html,而没有 Content-Type 的是:text/html; charset-UTF-8)

Here's what I'm seeing, in case you get anything different:http://i.imgur.com/tA4p1yc.png(Looks like the one that works says Content-Type is text/html, and the one that doesn't has Content-Type: text/html; charset-UTF-8)

建议?(我认为 UTF-8 应该是正确的编码是否正确?)

Suggestions? (Am I correct that UTF-8 should be the correct encoding?)

为方便起见,我的两个文件的来源:

for convenience, my source for both files:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>utf-8</title>
</head>
<body>
<p>Make sure you don’t pack your toiletries or clothes for your travel day.</p>
</body>
</html>

推荐答案

您使用的是什么编辑器?如果您使用 CFBuilder2+,BOM 标记 应该通过默认.但是,如果您不是,并且您的编辑器没有设置 BOM 标记的设置,那么您需要将其用作 cfm 的第一行.

What editor are you using? If you're using CFBuilder2+ the BOM mark should made everything UTF-8 by default. However if you're not, and your editor has no settings on setting BOM mark, then you'll need to use this as the first line of your cfm.

<cfprocessingdirective pageEncoding="utf-8">

这篇关于ColdFusion 字符编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 19:41