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

  • <small id='jPw1h'></small><noframes id='jPw1h'>

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

        MongoDB PHP UTF-8 問題

        MongoDB PHP UTF-8 problems(MongoDB PHP UTF-8 問題)
        • <tfoot id='w2t87'></tfoot>
        • <i id='w2t87'><tr id='w2t87'><dt id='w2t87'><q id='w2t87'><span id='w2t87'><b id='w2t87'><form id='w2t87'><ins id='w2t87'></ins><ul id='w2t87'></ul><sub id='w2t87'></sub></form><legend id='w2t87'></legend><bdo id='w2t87'><pre id='w2t87'><center id='w2t87'></center></pre></bdo></b><th id='w2t87'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='w2t87'><tfoot id='w2t87'></tfoot><dl id='w2t87'><fieldset id='w2t87'></fieldset></dl></div>

            <tbody id='w2t87'></tbody>

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

              <legend id='w2t87'><style id='w2t87'><dir id='w2t87'><q id='w2t87'></q></dir></style></legend>
                  <bdo id='w2t87'></bdo><ul id='w2t87'></ul>
                • 本文介紹了MongoDB PHP UTF-8 問題的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  假設我需要插入以下文檔:

                  Assume that I need to insert the following document:

                  {
                      title: 'Péter'
                  }
                  

                  (注意é)

                  當我使用以下 PHP 代碼時,它給了我一個錯誤......:

                  It gives me an error when I use the following PHP-code ... :

                  $db->collection->insert(array("title" => "Péter"));
                  

                  ... 因為它需要是 utf-8.

                  ... because it needs to be utf-8.

                  所以我應該使用這行代碼:

                  So I should use this line of code:

                  $db->collection->insert(array("title" => utf8_encode("Péter")));
                  

                  現在,當我請求文檔時,我仍然需要對其進行解碼... :

                  Now, when I request the document, I still have to decode it ... :

                  $document = $db->collection->findOne(array("_id" => new MongoId("__someID__")));
                  $title = utf8_decode($document['title']);
                  

                  有什么方法可以使這個過程自動化?我可以更改 MongoDB 的字符編碼嗎(我正在遷移使用 cp1252 West Europe (latin1) 的 MySQL 數據庫?

                  Is there some way to automate this process? Can I change the character-encoding of MongoDB (I'm migrating a MySQL-database that's using cp1252 West Europe (latin1)?

                  我已經考慮過更改 Content-Type-header,問題是所有靜態字符串(硬編碼)都不是 utf8...

                  I already considered changing the Content-Type-header, problem is that all static strings (hardcoded) aren't utf8...

                  提前致謝!提姆

                  推薦答案

                  JSON 和 BSON 只能編碼/解碼有效的 UTF-8 字符串,如果您的數據(包括輸入)不是 UTF-8 則需要在傳遞之前對其進行轉換它到任何 JSON 依賴系統,像這樣:

                  JSON and BSON can only encode / decode valid UTF-8 strings, if your data (included input) is not UTF-8 you need to convert it before passing it to any JSON dependent system, like this:

                  $string = iconv('UTF-8', 'UTF-8//IGNORE', $string); // or
                  $string = iconv('UTF-8', 'UTF-8//TRANSLIT', $string); // or even
                  $string = iconv('UTF-8', 'UTF-8//TRANSLIT//IGNORE', $string); // not sure how this behaves
                  

                  我個人更喜歡第一個選項,請參閱iconv() 手冊頁.其他替代方案包括:

                  Personally I prefer the first option, see the iconv() manual page. Other alternatives include:

                  • mb_convert_encoding()
                  • utf8_encode(utf8_decode($string))

                  您應該始終確保您的字符串是 UTF-8 編碼的,即使是用戶提交的字符串,但是既然您提到要從 MySQL 遷移到 MongoDB,您是否嘗試過將當前數據庫導出到 CSV 并使用導入Mongo 附帶的腳本?他們應該處理這個...

                  You should always make sure your strings are UTF-8 encoded, even the user-submitted ones, however since you mentioned that you're migrating from MySQL to MongoDB, have you tried exporting your current database to CSV and using the import scripts that come with Mongo? They should handle this...

                  我提到 BSON 只能處理 UTF-8,但我不確定這是否完全正確,我有一個模糊的想法 BSON 使用 UTF-16 或 UTF-32編碼/解碼數據,但我現在無法檢查.

                  I mentioned that BSON can only handle UTF-8, but I'm not sure if this is exactly true, I have a vague idea that BSON uses UTF-16 or UTF-32 to encode / decode data, but I can't check now.

                  這篇關于MongoDB PHP 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 找不到驅動程序)

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

                  1. <tfoot id='xO2Dj'></tfoot>

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

                      • <legend id='xO2Dj'><style id='xO2Dj'><dir id='xO2Dj'><q id='xO2Dj'></q></dir></style></legend>
                          <tbody id='xO2Dj'></tbody>
                          • <bdo id='xO2Dj'></bdo><ul id='xO2Dj'></ul>

                            主站蜘蛛池模板: 美女视频一区二区 | 久久涩涩| 男人天堂99 | 国产国产精品 | 日本午夜免费福利视频 | 日韩在线视频免费观看 | 91免费在线 | 三级特黄特色视频 | 97国产成人 | 久久高清| 国产精品成人久久久久a级 久久蜜桃av一区二区天堂 | 九色在线视频 | 欧美理论片在线观看 | 欧美在线观看一区 | 欧美色视频免费 | 一区二区三区四区在线视频 | 久久精品欧美一区二区三区麻豆 | 999久久久精品 | 欧美精品一二三区 | 国产免费xxx | 国产精品99久久久精品免费观看 | 国产一区二区成人 | 日韩久草| 337p日本欧洲亚洲大胆 | 国产精品成人一区二区 | 九九热在线免费观看 | 先锋资源在线 | 日韩午夜激情 | 美女视频网站久久 | 99精品一区二区 | 99精品视频一区二区三区 | 国产午夜精品久久 | 亚洲 欧美 另类 日韩 | av在线一区二区三区 | 日韩精品二区 | 国产精品久久久久久久久免费 | 免费成人高清 | 国产成人久久精品 | 久久精品二区亚洲w码 | 美女露尿口视频 | 日韩靠逼 |