Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
196 views
in Technique[技术] by (71.8m points)

sql - How to set the encoding for displaying Cyrillic in the response? odbc_connect()

Can you please tell me how to set the encoding for the correct display of the Cyrillic alphabet?

function getTripHistory($smart_card = "10201") {
$serverName = "[ip]webptp, [port]";
$conn = odbc_connect("[DSN Name in Data source Administtator]", "*", "*", SQL_CUR_USE_DRIVER);
if ($conn) {
  $query = "select distinct top 10 tr.DeviceDate, ev.Name as Event, acts.Name as TypeAction, tr.Amount, curr.Name
  from SmartCardHardwareAccounts as scha 
  left join SmartCards as sc on scha.SmartCardId=sc.Id
  left join Transactions as tr on tr.SmartCardId = sc.Id
  left join Currencies as curr on curr.Id = scha.Currency
  left join Actions as acts on tr.ActionId = acts.Id
  left join Events as ev on ev.id=tr.EventId
  left join Reports as rpts on tr.ReportId = rpts.Id
  WHERE YEAR(tr.DeviceDate) = YEAR(GETDATE()) and MONTH(tr.DeviceDate) = MONTH(GETDATE()) and curr.Id = 10333 and sc.Id = ".$smart_card.";";
  $result = odbc_exec($conn, $query);
  $table = "<table>";
  if (!$result) {
    echo "Нет записей :(
$query";
  } else {
    while(odbc_fetch_row($result)) {
      $table .= "<tr>";
      for($i = 1; $i <= odbc_num_fields($result); $i++) {
        $col_name = odbc_field_name($result, $i);
        $table .= "<td>".odbc_result($result, $i)."</td>";
      }
      $table .= "</tr>";
    }
    $table .= "</table>";
    echo $table;
  }
}
}

В ответе postman, также и в браузере: enter image description here

question from:https://stackoverflow.com/questions/65902521/how-to-set-the-encoding-for-displaying-cyrillic-in-the-response-odbc-connect

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...