如何在utf-8中将sqlite打印到文件? [英] How to print sqlite to file in utf-8?

查看:85
本文介绍了如何在utf-8中将sqlite打印到文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在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控制台

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆