KevinBui
KevinBui

Reputation: 1099

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?

Upvotes: 0

Views: 767

Answers (1)

Ivan Ustûžanin
Ivan Ustûžanin

Reputation: 86

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.

Upvotes: 1

Related Questions