为什么我得到 而不是双qoutes?

时间:2022-03-24 22:50:26

I am trying to call some data from my local database to my extension using PHP. But while calling I don't know why the double quotes is shown as �. so can some help me out with this.

我试图使用PHP将我的本地数据库中的一些数据调用到我的扩展。但在打电话时我不知道为什么双引号显示为 。所以有些人可以帮助我解决这个问题。

I also tried using

我也试过用

htmlspecialchars()

but it did not help at all.

但它根本没有帮助。

thank you

3 个解决方案

#1


0  

Try this

$var = "YOUR TEXT";
$foo = mb_substr($var,0,142, "utf-8");

DESCRIPTION : If you see that character (� U+FFFD "REPLACEMENT CHARACTER") it usually means that the text itself is encoded in some form of single byte encoding but interpreted in one of the unicode encodings (UTF8 or UTF16).

描述:如果您看到该字符( U+ FFFD“REPLACEMENT CHARACTER”),通常意味着文本本身以某种形式的单字节编码进行编码,但在其中一种unicode编码(UTF8或UTF16)中进行解释。

If it were the other way around it would (usually) look something like this: ä.

如果它是另一种方式它(通常)看起来像这样:Ã。

Probably the original encoding is ISO-8859-1, also known as Latin-1. You can check this without having to change your script: Browsers give you the option to re-interpret a page in a different encoding -- in Firefox use "View" -> "Character Encoding".

可能原始编码是ISO-8859-1,也称为Latin-1。您可以在不更改脚本的情况下进行检查:浏览器为您提供了以不同编码重新解释页面的选项 - 在Firefox中使用“查看” - >“字符编码”。

IF ABOVE THING IS NOT WORKING TRY THIS:

如果超过这件事就不起作用了:

To make the browser use the correct encoding, add an HTTP header like this:

要使浏览器使用正确的编码,请添加如下HTTP标头:

header("Content-Type: text/plain; charset=ISO-8859-1");
or put the encoding in a meta tag:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

Alternatively you could try to read from the database in another encoding (UTF-8, preferably) or convert the text with iconv().

#2


0  

just try this header if it works means comment it

只要尝试这个标题,如果它的工作意味着评论它

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

#3


0  

Try this :

尝试这个 :

&#34; or &quot;

“或”

If you use an HTML entity name or a hexadecimal number, the character will always display correctly. This is independent of what character set (encoding) your page uses!

如果使用HTML实体名称或十六进制数字,则该字符将始终正确显示。这与您的页面使用的字符集(编码)无关!

#1


0  

Try this

$var = "YOUR TEXT";
$foo = mb_substr($var,0,142, "utf-8");

DESCRIPTION : If you see that character (� U+FFFD "REPLACEMENT CHARACTER") it usually means that the text itself is encoded in some form of single byte encoding but interpreted in one of the unicode encodings (UTF8 or UTF16).

描述:如果您看到该字符( U+ FFFD“REPLACEMENT CHARACTER”),通常意味着文本本身以某种形式的单字节编码进行编码,但在其中一种unicode编码(UTF8或UTF16)中进行解释。

If it were the other way around it would (usually) look something like this: ä.

如果它是另一种方式它(通常)看起来像这样:Ã。

Probably the original encoding is ISO-8859-1, also known as Latin-1. You can check this without having to change your script: Browsers give you the option to re-interpret a page in a different encoding -- in Firefox use "View" -> "Character Encoding".

可能原始编码是ISO-8859-1,也称为Latin-1。您可以在不更改脚本的情况下进行检查:浏览器为您提供了以不同编码重新解释页面的选项 - 在Firefox中使用“查看” - >“字符编码”。

IF ABOVE THING IS NOT WORKING TRY THIS:

如果超过这件事就不起作用了:

To make the browser use the correct encoding, add an HTTP header like this:

要使浏览器使用正确的编码,请添加如下HTTP标头:

header("Content-Type: text/plain; charset=ISO-8859-1");
or put the encoding in a meta tag:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

Alternatively you could try to read from the database in another encoding (UTF-8, preferably) or convert the text with iconv().

#2


0  

just try this header if it works means comment it

只要尝试这个标题,如果它的工作意味着评论它

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

#3


0  

Try this :

尝试这个 :

&#34; or &quot;

“或”

If you use an HTML entity name or a hexadecimal number, the character will always display correctly. This is independent of what character set (encoding) your page uses!

如果使用HTML实体名称或十六进制数字,则该字符将始终正确显示。这与您的页面使用的字符集(编码)无关!