Answer the question
In order to leave comments, you need to log in
Why is iconv not working properly?
Hello. Here is a piece of modx plugin code.
foreach ($rows as $row) {
$row[0] = iconv('CP1251','UTF-8',$row[0]);
$btn = "<a class='button show-form' data-flat='{$row[0]}:{$row[2]}:".number_format((int)$row[6], 0, ',', ' ')." руб.:".(!empty($row[7])?number_format($row[7], 0, ',', ' ').' руб.':"-").">Текст</a>";
$out .= "<tr>";
$out .= "<td>{$row[0]}</td>";
$out .= "<td>{$row[1]}</td>";
$out .= "<td>{$row[2]}</td>";
$out .= "<td>{$row[3]}</td>";
$out .= "<td>{$row[4]}</td>";
$out .= "<td>{$row[5]}</td>";
$out .= "<td class='nowrap'><span class='".(!empty($row[7])?'strikethrough': '')."'>".number_format((int)$row[6], 0, ',', ' ')." руб.</span></td>";
$out .= "<td class='nowrap action-price'>".(!empty($row[7])?number_format($row[7], 0, ',', ' ').' руб.': "")."</td>";
$out .= "<td>".(!empty($row[8])?iconv('CP1251','UTF-8',$row[8]): $btn)."</td>";
$out .= "</tr>";
//echo "<pre>";print_r(iconv('CP1251','UTF-8',$row[8])); echo "</pre>";
}
Answer the question
In order to leave comments, you need to log in
This means that you are sending text in one encoding, but specifying another ('CP1251').
To check, put somewhere the php-FILE test-case with ONE line = iconv(...)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question