• <tfoot id='9nFI0'></tfoot>

      1. <i id='9nFI0'><tr id='9nFI0'><dt id='9nFI0'><q id='9nFI0'><span id='9nFI0'><b id='9nFI0'><form id='9nFI0'><ins id='9nFI0'></ins><ul id='9nFI0'></ul><sub id='9nFI0'></sub></form><legend id='9nFI0'></legend><bdo id='9nFI0'><pre id='9nFI0'><center id='9nFI0'></center></pre></bdo></b><th id='9nFI0'></th></span></q></dt></tr></i><div id='9nFI0'><tfoot id='9nFI0'></tfoot><dl id='9nFI0'><fieldset id='9nFI0'></fieldset></dl></div>
          <bdo id='9nFI0'></bdo><ul id='9nFI0'></ul>
      2. <small id='9nFI0'></small><noframes id='9nFI0'>

        <legend id='9nFI0'><style id='9nFI0'><dir id='9nFI0'><q id='9nFI0'></q></dir></style></legend>

        如何在 PHP 中更改 PDO/SQLite 连接的字符编码?

        时间:2023-10-05
        <legend id='vIdxL'><style id='vIdxL'><dir id='vIdxL'><q id='vIdxL'></q></dir></style></legend>
          <tbody id='vIdxL'></tbody>

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

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

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

                <tfoot id='vIdxL'></tfoot>

                  本文介绍了如何在 PHP 中更改 PDO/SQLite 连接的字符编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我的 php-gtk 应用程序遇到了一个小问题,它一直运行到非 utf8 字符串中,我发现问题出在数据库连接上,即使数据库应该是 UTF-8.

                  I'm having a little problem with a php-gtk app that keeps running into non-utf8 strings, I had found that the problem is in the database connection, even when the database is supposed to be in UTF-8.

                  我曾尝试使用SET CHARACTER SET utf8"(MySQL 方式)和SET NAMES UTF8",但没有任何反应(在SQLite 理解的查询语言"页面,所以我对此并不感到惊讶).

                  I had tried with the "SET CHARACTER SET utf8"(MySQL way) and the "SET NAMES UTF8" and nothing happen (there isn't any information about none of this commands in the "Query Language Understood by SQLite " page either, so I'm not surprised about that).

                  PD:也许连接已经是 UTF-8 而数据不是,但如果有办法改变连接编码,这个问题仍然有用.

                  PD: Maybe the connection is already in UTF-8 and the data isn't, but if there is a way to change the connection encoding this question would still be useful.

                  推荐答案

                  据我所知,SQLite 只有一个字符集设置,这是在每个数据库级别上的.您无法更改连接上的编码.

                  As far as I can tell, SQLite only has one setting for charset, which is on a per-database level. You can't change the encoding on the connection.

                  C API 有两种不同的方式打开连接,可以是 UTF-8 或 UTF-16.我希望 PHP 的 SQLite 模块(以及 PDO)简单地使用 UTF-8 版本.如果这是正确的,我希望 SQLite 连接始终是 UTF-8.这意味着您应该使用 utf8_encode 手动编码/解码字符串/utf8_decode.

                  The C API has two different ways of opening a connection, either as UTF-8 or UTF-16. I would expect PHP's SQLite module (And thus PDO) to simply use the UTF-8 version. If that's correct, I would expect that a SQLite connection is always UTF-8. This means that you ought to manually encode/decode strings with utf8_encode/utf8_decode.

                  另见:http://www.alberton.info/dbms_charset_settings_explained.html

                  这篇关于如何在 PHP 中更改 PDO/SQLite 连接的字符编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PDOException: 您不能序列化或反序列化 PDO 实例 下一篇:lastInsertId 在 Postgresql 中不起作用

                  相关文章

                  最新文章

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

                      <bdo id='7Dw06'></bdo><ul id='7Dw06'></ul>
                  1. <tfoot id='7Dw06'></tfoot>

                      <small id='7Dw06'></small><noframes id='7Dw06'>