Single quotes showing as a diamond-shaped question mark in browsers (no database or PHP)

I am working with a webpage in which I switched the character set from iso-8859-1 to utf-8. The top of the page reads as follows:

<!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> <title>[title of site]</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

I use only ASCII characters on the page, and since the utf-8 encoding decrypts ASCII, this should be fine. However, single quotes in the text appear as question marks surrounded by black diamonds. I have confirmed that these are single ASCII quotes (not direct quotes).

I read a lot on the Internet, which describes solutions to problems related to PHP, magic quotes, database configuration, etc. However, this is a flat HTML page that is not displayed by any programs.

In addition, many who have this problem are told to switch to UTF-8 to fix the problem. That is how I presented the problem.

Please see http://mch.blackcatwebinc.com/src/events.html to see this problem.

+7
source share
6 answers

The only quotes in ASCII are the single quote (0x27 or 39) and the double quote (0x22 or 33). You have an 8-bit encoding that puts quotation marks in 145 (0x91) and 146 (0x92) called CP1252, this is the standard 8-bit West European encoding for Windows. If you want UTF-8, you need to convert it to UTF-8, since it is not valid UTF-8, a valid UTF-8 uses several bytes for characters above 127 (0x7F) and places open and close quotes in U + 2018 and U + 2019, respectively.

+5
source

According to W3C, meta charset

should be as close to the top of the head element as possible

From http://www.w3.org/International/questions/qa-html-encoding-declarations#metacontenttytype

So, I can try to put the meta tag above the title .

Also, as mentioned in the first answer by @ user1505373, UTFs are always capitalized and there is no space after = in any of the examples I saw.

+1
source

The source code is not saved in UTF-8, but Latin1 is CP1252, and those quotes are not simple quotes, but U + 2019 RIGHT Single quotes (encoded in Latin1). Save the source file in UTF-8 and it will work.

+1
source

The easiest fix is ​​to change UTF-8 to windows-1252 in the meta tag. This works because the server does not declare the encoding in the Content-Type header, so browsers and other clients will use the one specified in the meta tag.

Window name-1252 is the preferred MIME name for the 8-bit encoding of Windows Latin-1, also known as cp1252 and some other names (often distorted as "ANSI").

As @deceze explains, the actual data encoding is windows-1252, not UTF-8. You can alternatively change the actual encoding to UTF-8 by saving the file with the appropriate command in your development software. But it is really important that the declared encoding corresponds to the real one.

Another option is to use "escape sequences" for the apostrophe, for example &rsquo; . They work regardless of the encoding, but make the source code less legible.

+1
source

The only difference that I see between your tag and what is on the site I'm working on is the space after the semicolon, and that utf is lowercase on yours. Try using UTF.

0
source

All printable ASCII characters have equivalent HTML Entity code. Some of these characters are usually supported by most common OS fonts, some of which are classified as characters that lead us to a rendering problem.

What you have is a final single quote, and in order to get it correctly printed, you must use its entity code, or & # 146; respectively. If it is an open single quote, then you should use & # 145; instead of this.

Please note that there is no HTML name name for two ASCII characters (and a few more ), so you are required to select an entity code variant.

0
source

All Articles