久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <legend id='VsuzR'><style id='VsuzR'><dir id='VsuzR'><q id='VsuzR'></q></dir></style></legend>

    <small id='VsuzR'></small><noframes id='VsuzR'>

    1. <i id='VsuzR'><tr id='VsuzR'><dt id='VsuzR'><q id='VsuzR'><span id='VsuzR'><b id='VsuzR'><form id='VsuzR'><ins id='VsuzR'></ins><ul id='VsuzR'></ul><sub id='VsuzR'></sub></form><legend id='VsuzR'></legend><bdo id='VsuzR'><pre id='VsuzR'><center id='VsuzR'></center></pre></bdo></b><th id='VsuzR'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='VsuzR'><tfoot id='VsuzR'></tfoot><dl id='VsuzR'><fieldset id='VsuzR'></fieldset></dl></div>

          <bdo id='VsuzR'></bdo><ul id='VsuzR'></ul>

        <tfoot id='VsuzR'></tfoot>

      1. 將 SQL_Latin1_General_CP1_CI_AS 編碼為 UTF-8

        Encoding SQL_Latin1_General_CP1_CI_AS into UTF-8(將 SQL_Latin1_General_CP1_CI_AS 編碼為 UTF-8)
        • <bdo id='A7uaf'></bdo><ul id='A7uaf'></ul>
          <tfoot id='A7uaf'></tfoot>

          <i id='A7uaf'><tr id='A7uaf'><dt id='A7uaf'><q id='A7uaf'><span id='A7uaf'><b id='A7uaf'><form id='A7uaf'><ins id='A7uaf'></ins><ul id='A7uaf'></ul><sub id='A7uaf'></sub></form><legend id='A7uaf'></legend><bdo id='A7uaf'><pre id='A7uaf'><center id='A7uaf'></center></pre></bdo></b><th id='A7uaf'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='A7uaf'><tfoot id='A7uaf'></tfoot><dl id='A7uaf'><fieldset id='A7uaf'></fieldset></dl></div>

            1. <legend id='A7uaf'><style id='A7uaf'><dir id='A7uaf'><q id='A7uaf'></q></dir></style></legend>

              <small id='A7uaf'></small><noframes id='A7uaf'>

                  <tbody id='A7uaf'></tbody>

                  本文介紹了將 SQL_Latin1_General_CP1_CI_AS 編碼為 UTF-8的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在使用 DomDocument 用 PHP 生成 XML 文件,我需要處理亞洲字符.我正在使用 pdo_mssql 驅動程序從 MSSQL2008 服務器中提取數據,并對 XML 屬性值應用 utf8_encode().只要沒有特殊字符,一切正常.

                  I'm generating a XML file with PHP using DomDocument and I need to handle asian characters. I'm pulling data from the MSSQL2008 server using the pdo_mssql driver and I apply utf8_encode() on the XML attribute values. Everything works fine as long as there's no special characters.

                  服務器是 MS SQL Server 2008 SP3

                  The server is MS SQL Server 2008 SP3

                  數據庫、表和列的排序規則都是SQL_Latin1_General_CP1_CI_AS

                  The database, table and column collation are all SQL_Latin1_General_CP1_CI_AS

                  我使用的是 PHP 5.2.17

                  I'm using PHP 5.2.17

                  這是我的 PDO 對象:

                  Here's my PDO object:

                  $pdo = new PDO("mssql:host=MyServer,1433;dbname=MyDatabase", user123, password123);
                  

                  我的查詢是一個基本的 SELECT.

                  My query is a basic SELECT.

                  我知道將特殊字符存儲到 SQL_Latin1_General_CP1_CI_AS 列中并不是很好,但理想情況下,讓它在不更改的情況下工作會很好,因為其他非 PHP 程序已經使用該列并且它工作正常.在 SQL Server Management Studio 中,我可以正確地看到亞洲字符.

                  I know storing special characters into SQL_Latin1_General_CP1_CI_AS columns isn't great, but ideally it would be nice to make it work without changing it, because other non-PHP programs already use that column and it works fine. In SQL Server Management Studio I can see the asian characters correctly.

                  考慮到以上所有細節,我應該如何處理數據?

                  Considering all the details above, how should I process the data?

                  推薦答案

                  我找到了解決方法,所以希望這對某人有所幫助.

                  I found how to solve it, so hopefully this will be helpful to someone.

                  首先,SQL_Latin1_General_CP1_CI_AS 是 CP-1252 和 UTF-8 的奇怪組合.基本字符是 CP-1252,所以這就是為什么我所要做的就是 UTF-8 并且一切正常.亞洲和其他 UTF-8 字符以 2 個字節編碼,php pdo_mssql 驅動程序似乎討厭不同長度的字符,因此它似乎對 varchar(而不是 nvarchar)執行 CAST,然后所有 2 個字節字符都變成問號('?').

                  First, SQL_Latin1_General_CP1_CI_AS is a strange mix of CP-1252 and UTF-8. The basic characters are CP-1252, so this is why all I had to do was UTF-8 and everything worked. The asian and other UTF-8 characters are encoded on 2 bytes and the php pdo_mssql driver seems to hate varying length characters so it seems to do a CAST to varchar (instead of nvarchar) and then all the 2 byte characters become question marks ('?').

                  我通過將其轉換為二進制文件來修復它,然后使用 php 重建文本:

                  I fixed it by casting it to binary and then I rebuild the text with php:

                  SELECT CAST(MY_COLUMN AS VARBINARY(MAX)) FROM MY_TABLE;
                  

                  在 php 中:

                  //Binary to hexadecimal
                  $hex = bin2hex($bin);
                  
                  //And then from hex to string
                  $str = "";
                  for ($i=0;$i<strlen($hex) -1;$i+=2)
                  {
                      $str .= chr(hexdec($hex[$i].$hex[$i+1]));
                  }
                  //And then from UCS-2LE/SQL_Latin1_General_CP1_CI_AS (that's the column format in the DB) to UTF-8
                  $str = iconv('UCS-2LE', 'UTF-8', $str);
                  

                  這篇關于將 SQL_Latin1_General_CP1_CI_AS 編碼為 UTF-8的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)

                      <tbody id='IURM6'></tbody>
                    1. <legend id='IURM6'><style id='IURM6'><dir id='IURM6'><q id='IURM6'></q></dir></style></legend>
                        <bdo id='IURM6'></bdo><ul id='IURM6'></ul>

                        <small id='IURM6'></small><noframes id='IURM6'>

                        <i id='IURM6'><tr id='IURM6'><dt id='IURM6'><q id='IURM6'><span id='IURM6'><b id='IURM6'><form id='IURM6'><ins id='IURM6'></ins><ul id='IURM6'></ul><sub id='IURM6'></sub></form><legend id='IURM6'></legend><bdo id='IURM6'><pre id='IURM6'><center id='IURM6'></center></pre></bdo></b><th id='IURM6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='IURM6'><tfoot id='IURM6'></tfoot><dl id='IURM6'><fieldset id='IURM6'></fieldset></dl></div>

                          <tfoot id='IURM6'></tfoot>
                          1. 主站蜘蛛池模板: 亚洲va在线va天堂va狼色在线 | 亚洲国产精品一区二区三区 | 亚洲国产成人精品久久久国产成人一区 | 久久久精品国产 | 国产精品射| 久久久精品一区 | 欧美黑人又粗大 | 91视频免费在观看 | 国产在线观看不卡一区二区三区 | 色橹橹欧美在线观看视频高清 | 日本高清在线一区 | 在线看日韩 | 精品欧美一区二区三区免费观看 | 九色在线| 91久久久久久久久久久 | 精品欧美黑人一区二区三区 | 中国人pornoxxx麻豆 | 精品中文字幕一区二区三区 | 日本在线视 | 国产一区h | 成年人精品视频 | 久久久免费电影 | 一区二区三区中文字幕 | 欧美日韩专区 | 精品一区二区三区在线播放 | 欧美成人二区 | 成人午夜免费网站 | 欧美一区二区网站 | 国产精品久久久久久婷婷天堂 | 国产精品无码永久免费888 | 日韩视频一区在线观看 | 久久久蜜臀国产一区二区 | 亚洲 中文 欧美 日韩 在线观看 | 国产精品亚洲综合 | 欧美日韩在线一区二区 | 欧美黄色片在线观看 | 久久久久久天堂 | 在线观看视频亚洲 | 久久久久久久国产精品视频 | 一级黄色绿像片 | 成人做爰69片免费观看 |