Altenrion
Altenrion

Reputation: 774

MsSQL + Apache + nginx encoding trouble

I'm executing some requests to the remote mssql database and successfully get the response. Linux server RHEL 6 is configured to connect to mssql via php pdo_dblib.

But the trouble is that the encoding is incorrect on some level. I have default charset = UTF-8 in Apache httpd.conf, same in freetds.conf, and : Content-Type:text/html; charset=utf-8 .

But when I try to get data I see ASCII And smth else. Also Russian letters can be read only after using iconv( 'cp1251', 'utf-8', $row_v );

foreach($rowContent as $row){
    $html .= '<tr>';
    foreach ($row as $row_k=>$row_v)
        $html .= '<td>'.$row_v.' ---> '. iconv( 'cp1251', 'utf-8', $row_v ).' - '. mb_detect_encoding($row_v)  .' </td>';
    $html .= '</tr>';
}
$html .= '</table>';

return $html;

enter image description here

Upvotes: 0

Views: 548

Answers (1)

serhat
serhat

Reputation: 11

I had a similar problem once. And after all the research I got a solution. Check if your php files are encoded as UTF-8 without BOM. You must save your files encoded as utf-8 without bom.

Upvotes: 1

Related Questions