0

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

w3spi
  • 4,380
  • 9
  • 47
  • 80
Altenrion
  • 764
  • 3
  • 14
  • 35
  • consult http://stackoverflow.com/questions/279170/utf-8-all-the-way-through and try passing UTF8 in the connection before querying. – Funk Forty Niner Sep 08 '15 at 13:19
  • read the topic, thanks, but... I have MsSQL and cannot use things like set NAMES utf-8 & close to it because it is not mysql. Default charset of apache is set , pdo_dblib(freetds) driver also has UTF-8 encoding, The only strange to me is that when I call `SELECT SERVERPROPERTY('Collation')` database returns `Cyrillic_General_CI_AS` – Altenrion Sep 08 '15 at 13:25
  • Data base is remote and I cannot get in touch with admins. so I have to find out where is the main trouble myself. Also I cannot change its attributes and any conf in it. only from side of my rhel6 linux server. – Altenrion Sep 08 '15 at 13:33

1 Answers1

1

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.

serhat
  • 11
  • 4