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

3
  • consult stackoverflow.com/questions/279170/utf-8-all-the-way-through and try passing UTF8 in the connection before querying. Commented Sep 8, 2015 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 Commented Sep 8, 2015 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. Commented Sep 8, 2015 at 13:33

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.