How to convert "¢ ÐμÑ" (this is a Russian word) into something readable?

I got a MySQL DB that contains a UTF8 column with such "¢ ÐμÑ" records. PHP mb_detect_encoding () told me that it is UTF-8. How can I turn this “horror” into something readable?

thank

+3
source share
2 answers

I assume that you have a byte string "\xd0\xa2\xd0\xb5\xd1", then it will be a UTF-8 character encoded character form (plus the next one byte, which is half a character).

echo(), , UTF-8, :

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

 something: <?php echo htmlspecialchars($something); ?>

, , , .php, UTF-8, , ASCII. ( Windows UTF-8 , .)

, UTF-8, iconv(), , , Windows 1251 ('cp1251'). UTF-8 , .

:

mysql_set_charset ( "utf8", $db) - ""

mysql_set_charset('utf8') . , meta, , ( View- > Encoding UTF-8).

Ð¢ÐµÑ UTF-8, , . , mysql_set_charset, , , SQL, .

, , , " , iconv() UTF-8 ISO-8859-1. UTF-8.

[: 2]

iconv ( "UTF-8", "ISO-8859-1", $row ['name']), : iconv(): .

, UTF-8. , UTF-8 , UTF-8 . , "\xd0\xa2\xd0\xb5\xd1" (, ISO-8859-1, "ТеÑ"), , "Ñ" UTF-8. UTF-8 , .

, , , .

, $row['name'], mysql_set_charset("utf8", $db)

, UTF-8 ( View- > Encoding), , , echo(); , .

, , echo bin2hex($row['name']);. , "\xd0\xa2\xd0\xb5\xd1" d0a2d0b5d1, , .

+9

UTF8. .

+1

Source: https://habr.com/ru/post/1753526/


All Articles