If you notice the two line below, the double quotes are not the same. the first one is what i have a problem with. They are shown as strange characters like - �. But the secound line double quotes is just fine.

“this is line 1.”

and

"this is line 2."

What is the difference between the two double quotes, and how can the special characters be prevented?

有帮助吗?

解决方案 3

In line 1, those quotes are sometimes called "smart quotes". They are ascii code #147 and #148.

In line 2, those are "normal" quotes, ascii code #34.

Because character definition beyond ascii code #127 can become somewhat arbritrary depending on the font used, I try to avoid using the smart quote characters.

Micorosoft Word will (infamously) convert normal quotes to "smart quotes". This "feature" can be turned off in settings.

其他提示

You should make sure, your PHP script uses utf-8, as well as the html meta tag says utf-8.

For the first thing, try in PHP (before any output occurs)

header('Content-Type: text/html; charset=utf-8');

In php, you can escape most HTML specialchars with "htmlentities". See http://php.net/manual/de/function.htmlentities.php

First line you copied probably from MS word/MS Excel. Their double quotes are different and will not parse properly using HTTP. You need to convert them using UTF-8 charset and then display on your website.

This issue occurred to me when I copy pasted text text from word document to label. If you observe carefully Word document double quotes looked little curvy opposed to HTML double quotes. Just removing copy pasted doubled quotes and typing again helped. ” - This from Word ." - This is from HTML . You can see the difference yourselves

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top