sql server2008数据库中的数据包含了特殊字符""用sqlsrv里面的SQLSRV_ENC_BINARY指定了返回数据为原始数据流.再转码,才正常显示
但封装的pdo fetch直接把返回的数据转码为了问号,不是页面字体的问题,也不是数据库编码问题
以下是微软官方的实例
<?php
/*Connect to the local server using Windows Authentication and specify
the AdventureWorks database as the database in use. */
$serverName = "(local)";
$connectionInfo = array( "Database"=>"AdventureWorks");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false )
{
     echo "Could not connect.\n";
     die( print_r( sqlsrv_errors(), true));
}/* Set up the Transact-SQL query. */
$tsql = "SELECT ReviewerName, 
                ReviewDate,
                Rating, 
                Comments 
         FROM Production.ProductReview 
         WHERE ProductID = ? 
         ORDER BY ReviewDate DESC";/* Set the parameter value. */
$productID = 709;
$params = array( $productID);/* Execute the query. */
$stmt = sqlsrv_query($conn, $tsql, $params);
if( $stmt === false )
{
     echo "Error in statement execution.\n";
     die( print_r( sqlsrv_errors(), true));
}/* Retrieve and display the data. The first and third fields are
retrieved according to their default types, strings. The second field
is retrieved as a string with 8-bit character encoding. The fourth
field is retrieved as a stream with 8-bit character encoding.*/
while ( sqlsrv_fetch( $stmt))
{
   echo "Name: ".sqlsrv_get_field( $stmt, 0 )."\n";
   echo "Date: ".sqlsrv_get_field( $stmt, 1, 
                       SQLSRV_PHPTYPE_STRING( SQLSRV_ENC_CHAR))."\n";
   echo "Rating: ".sqlsrv_get_field( $stmt, 2 )."\n";
   echo "Comments: ";
   $comments = sqlsrv_get_field( $stmt, 3, 
                            SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY));

   fpassthru( $comments);
   echo "\n"; 
}/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
?>