English 中文(简体)
Special characters are not supported
原标题:

I am having problem to display the special characters like ’, é in Firefox and IE. But these characters are supported for the local server.

I have used the following

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

Can anyone suggest me what the might be? Thanks in advance.

问题回答

You ve set the charset to iso-8859-1 - are you sure that s how they re encoded in your HTML?

In Firefox, try changing the charset using View -> Character Encoding (for your page it should have "Western (ISO-8859-1)" selected), and see if it works with another character encoding. If it does, consider either re-encoding your HTML into UTF-8, or changing the charset in your meta tag.

As Dominic says, checking you re encoding your HTML with the right charset in your meta tag would be the first step. There s info on charsets and encoding here. Whether you need to change the charset meta tag depends on the language the page is in. If your page is in English but just has the odd character that needs accents etc., the easiest way is to use the character code, for example the character code for é is &eacute; One of the many lists of character entities available online can be found here.

Alternatively, if your page is basically in English, but has small sections in another language, CSS2 has a lang attribute that can be used to style text in other languages appropriately. There s more info about the four different ways to apply language styles here. You can use the :lang() pseudo-class selector, the [lang |= "..."] selector that matches the beginning of the value of a language attribute, the [lang = "..."] selector that exactly matches the value of a language attribute, or a generic class or id selector.

If a small portion of your site was in another language such as Hebrew, you could also use CSS and a span to signify a change in the reading direction of the text, for example:

<p style="direction: rtl; unicode-bidi: embed;">
This is a paragraph written right-to-left.
</p>

or

<p>
This paragraph is written left-to-right except for <span style="direction: rtl; unicode-bidi: bidi-override;">these words</span> which were written right-to-left.
</p>

These examples (taken from here) show the style being applied inline, but you could also set the styles up in an external stylesheet).

You ve set the charset in the document s meta tag, which works when you re viewing it as a file, but if the web server is providing a charset value, that takes priority. Check the HTTP headers that the web server is providing; one way is with the Firefox extension Live HTTP Headers. If it s something different, you have to tell the web server what you re doing or else reencode the document to match.

How to set the encoding varies between web servers. Apache, for example, lets you specify the charset globally, per-file in .htaccess, or by renaming the file to example.html.latin1.

Use HTML Entities like &aacute; or &#225; and the browser should sort it out.

Here is a list:

http://www.utexas.edu/learn/html/spchar.html

change your encoding meta tag to:

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




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签