久久久久久久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的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問題描述

                  我正在使用 DomDocument 用 PHP 生成 XML 文件,我需要處理亞洲字符.我正在使用 pdo_mssql 驅(qū)動(dòng)程序從 MSSQL2008 服務(wù)器中提取數(shù)據(jù),并對(duì) XML 屬性值應(yīng)用 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.

                  服務(wù)器是 MS SQL Server 2008 SP3

                  The server is MS SQL Server 2008 SP3

                  數(shù)據(jù)庫(kù)、表和列的排序規(guī)則都是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 對(duì)象:

                  Here's my PDO object:

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

                  我的查詢是一個(gè)基本的 SELECT.

                  My query is a basic SELECT.

                  我知道將特殊字符存儲(chǔ)到 SQL_Latin1_General_CP1_CI_AS 列中并不是很好,但理想情況下,讓它在不更改的情況下工作會(huì)很好,因?yàn)槠渌?PHP 程序已經(jīng)使用該列并且它工作正常.在 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.

                  考慮到以上所有細(xì)節(jié),我應(yīng)該如何處理數(shù)據(jù)?

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

                  推薦答案

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

                  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 個(gè)字節(jié)編碼,php pdo_mssql 驅(qū)動(dòng)程序似乎討厭不同長(zhǎng)度的字符,因此它似乎對(duì) varchar(而不是 nvarchar)執(zhí)行 CAST,然后所有 2 個(gè)字節(jié)字符都變成問號(hào)('?').

                  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 ('?').

                  我通過將其轉(zhuǎn)換為二進(jìn)制文件來(lái)修復(fù)它,然后使用 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);
                  

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

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

                  相關(guān)文檔推薦

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

                      <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. 主站蜘蛛池模板: 求毛片 | 久久久国产精品一区 | www.亚洲一区 | 欧美视频精品 | 日韩中文字幕一区二区 | 亚洲国产福利视频 | 国产综合视频 | 在线播放国产一区二区三区 | 91xxx在线观看 | 天天综合网天天综合 | 一级毛片视频在线 | 日日操夜夜操天天操 | 亚洲高清av在线 | 午夜av在线 | 精品乱码一区二区三四区 | av色站| 九九热这里 | 欧美成人精品在线观看 | 欧美精品一区二区三区在线播放 | 国产一区2区 | 午夜国产 | 一区二区三区免费观看 | 99re99| 日韩精品区 | 欧美一区二区三区在线视频 | 国产精品中文 | 黄色av网站免费看 | 毛片高清 | 毛片免费在线观看 | 久久国产精品免费 | 超碰在线人人 | 一区二区三区av | 亚洲第1页| 91福利在线观看视频 | 免费成人高清在线视频 | 亚洲国产精品一区二区三区 | 欧美伦理一区 | 亚洲国产福利视频 | 亚洲国产成人在线 | 高清免费在线 | 国产精品99 |