Answer the question
In order to leave comments, you need to log in
How to convert CP1252 to UTF-8 in PHP?
Faced a problem. On sockets I receive a miracle line. At the PHP level, I can't recode it!
<?php
$str = 'Çíà÷åíèå ADDRESS[0][48] íå íàéäåíî';
// mb_detect_encoding покажет UTF-8, но на деле строка в CP1252
echo mb_detect_encoding($str) . PHP_EOL;
// Пытаемся преобразовать хоть в какую кодировку:
echo mb_convert_encoding($str, 'CP1251') . PHP_EOL;
echo mb_convert_encoding($str, 'ASCII') . PHP_EOL;
echo mb_convert_encoding($str, 'UTF-8') . PHP_EOL;
// и прочие варианты тоже не работают
Answer the question
In order to leave comments, you need to log in
$str = 'Çíà÷åíèå ADDRESS[0][48] íå íàéäåíî';
$str = iconv('utf-8', 'cp1252', $str);
echo iconv('cp1251', 'utf-8', $str);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question