php 没有正确地将 ascii 转换为 utf-8

php not converting ascii to utf-8 correctly

php : 7.3

laravel : 7

问题是我通过 curl 从一些网站获取信息,输出是这样的:

هکس استور : ۶۱٫۷۴۹٫۰۰۰ تومان

当我从 laravel return 或在某个页面打印它时,它将是这样的:

آداک : ۵۸٫۳۴۴٫۰۰۰ تومان پارسان می : ۵۸٫۴۵۰٫۰۰۰ تومان های اپل : ۵۸٫۴۹۹٫۰۰۰ تومان تکسنولی : ۵۸٫۸۸۸٫۰۰۰ تومان لوتوس : ۵۹٫۰۹۹٫۰۰۰ تومان گجت : ۵۹٫۳۰۰٫۰۰۰ تومان های اپل : ۵۹٫۹۹۹٫۰۰۰ تومان آروند : ۶۱٫۰۸۰٫۰۰۰ تومان هکس استور : ۶۱٫۷۴۹٫۰۰۰

还可以。

但我想用电报发送它,当我发送它时,输出如下所示:

我试图找出什么编码是 whit mb_detect_encoding 并且它说它是 ASCII 我也试图将它转换为 utf-8 但它似乎 ASCCI 是一种 utf-8 并且无论如何它让我发疯。

这是我尝试过的一些方法,其中 none 有效。

iconv('ASCII', 'UTF-8', $text); // output : the same ascii charachters and after it when detect it with mb_detect_encoding its says it is ASCII yet

utf8_encode($text) // output : the same ascii charachters and after it when detect it with mb_detect_encoding its says it is ASCII yet

mb_convert_encoding($text,'utf-8' , 'ascii'); // output : the same ascii charachters and after it when detect it with mb_detect_encoding its says it is ASCII yet

// i also used forcetoutf8 package
use \ForceUTF8\Encoding;
$utf8_string = Encoding::toUTF8($utf8_or_latin1_or_mixed_string);
// but the output was same

提前致谢。

当然 ن 是 ASCII,因为这与文本编码有关,而不是所有这些字符加在一起可能意味着什么。你这里有一个 HTML 实体,它必须被解码成它们代表的字符。

在 PHP 中,您将使用 html_entity_decode() on an entire text. See also Wikipedia: HTML > Entities