2
votes

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.

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.

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:

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)

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

Edit: 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>
1
can you show the cfm code ? - Dungeon Hunter
The CFM code is exactly the same as the HTML source code in the example above it, even though the rendered output is different. (After creating the HTM file I just did Save As and then replaced the extension.) - Michael

1 Answers

6
votes

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">