Log in

View Full Version : Resolved UTF-8 and special characters.



jlizarraga
01-12-2009, 10:02 PM
Hi all,

Just a few simple questions about UTF-8 and special characters:

1. When using UTF-8 and XHTML/HTML, is it required that you use a character code to display a special character, or can you just write the plaintext special character? For instance, a small "A" with an accent is "U+00E1" in Unicode and "á" in HTML.

2. If you can just write the plaintext character with UTF-8 encoding, must the server also be configured to support this?

My situation:

All my pages are UTF-8. In HTML, I must use the HTML escape code or I get the question-mark-in-diamond (http://i27.tinypic.com/szwkma.png) symbol in Firefox. In Javascript, I must use the UTF-8 escape code or I get the same diamond question mark.

I turned to Google, but found confusing answers. A common answer I found to any sort of special character problem was to simply switch your document to UTF-8 encoding and that all your special characters would render properly, but that is clearly not the case as my situation seems to be the opposite. That's why I ask if there is a matching server setting for other languages.

Twey
01-13-2009, 02:56 AM
If they truly are in UTF-8, then you can type the character directly. You can use the HTML entity in any encoding, since they correspond directly to Unicode code points.

If you're having issues, there are two things to check: 1) that your server is sending the correct character set in the Content-Type header (if you don't know how to check, post a link and I'll look), and 2) that your editor is really saving your files in UTF-8.

jlizarraga
01-15-2009, 12:38 AM
Thanks for responding! Here is a great example:

http://redesign1.autofusion.com/espanol/serviceoverview.html

- I have Dreamweaver set to UTF-8.
- "charset=utf-8" is in the markup.
- Firefox's Page Info window shows the encoding as "UTF-8".
- The page gets some special characters right, others get question marks.

The only clue I have is that the area with the question marks is included with PHP like this:

<?php include "someFile.html" ?>

The file being included is just stripped out HTML, it doesn't have its own header and body and what not - could that be part of the problem?

jlizarraga
01-15-2009, 12:44 AM
Derp. That was the problem!

Fixed by adding the charset thinger to the file being included:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />