如何在utf-8中将sqlite打印到文件? [英] How to print sqlite to file in utf-8?
问题描述
我已经在Windows控制台中打开了sqlite3.exe
,并创建了一个带有特殊字符的数据库.
.dump
向我展示了带有特殊字符的sql查询.
然后我将输出更改为文件:.output file.sql
并执行.dump
命令.
当我使用.read file.sql
导入数据库时,缺少特殊字符.
我使用了pragma encoding="UTF-8";
,但它没有改变任何东西(我不知道是否应该这样做).
I've opened sqlite3.exe
in windows console and made a database with special characters.
.dump
showed me the sql query with special characters.
Then I changed output to file: .output file.sql
And executed the .dump
command.
The special characters were missing when I imported the database using .read file.sql
.
I used pragma encoding="UTF-8";
but it didn't change anything (I don't know if it should).
推荐答案
Windows控制台很多错误,使得无法将UTF-8与可移植I/O功能一起使用.
The Windows console makes it hard to use UTF-8 correctly, and the Microsoft compiler has lots of bugs that make it impossible to use UTF-8 with portable I/O functions.
如果您已在Windows控制台中输入数据,则这些字符串不是有效的UTF-8. 如果在Windows控制台中以正确的字符输出非ASCII字符串,则它是无效的UTF-8.
If you have entered data in the Windows console, those strings are not valid UTF-8. If a non-ASCII string is output with correct characters in the Windows console, it is not valid UTF-8.
要确保您的数据是有效的UTF-8,必须浏览文件. 或者,使用任何不使用控制台的SQLite Shell(例如SQLite Manager Firefox扩展).
To ensure that your data is valid UTF-8, you have to go through files. Alternatively, use any SQLite shell that does not use the console (such as the SQLite Manager Firefox extension).
这篇关于如何在utf-8中将sqlite打印到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!