简体   繁体   中英

sqlite3 .read command not working with unicode script

I used command .read script.sql (of command line tool sqlite3.exe that I've downloaded from https://www.sqlite.org/download.html ) to import data to an existing database sqlite. File script.sql was saved with notepad++ in encoding UTF8 without BOM , has content like this:

INSERT INTO "table1" VALUES('Các con cáo nâu nhanh chóng nhảy chó lười biếng');
INSERT INTO "table1" VALUES('速い茶色のキツネは、のろまなイヌに飛びかかっ');
INSERT INTO "table1" VALUES('빠른 갈색 여우가 게으른 개 점프');

But after I ran above command, data was convert to ansii, like this:

Các con cáo nâu nhanh chóng nhảy chó lÆ°á»i biếng
速ã„茶色ã®ã‚­ãƒ„ãƒã¯ã€ã®ã‚ã¾ãªã‚¤ãƒŒã«é£›ã³ã‹ã‹ã£
빠른 갈색 여우가 게으른 ê°œ ì í”„

Does anybody know how to solve the problem?

According to the source code, this is a bug in the sqlite3 tool. On Windows in interactive mode it unconditionally converts all input from ANSI to UTF-8, even from file.

To fix this issue line 488 of shell.c (an amalgamation, version 3.11.1) can be changed to:

if( stdin_is_interactive && in == stdin){

Just checked it and fixed my similar issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM