Derek Long
Derek Long

Reputation: 1219

Data ends up with incorrect encoding when reading SQL from a .sql file instead of executing it in SQLite Browser

I got this SQL statement that I wish to run on SQLite:

INSERT INTO tEntity (name) VALUES ('Roger Café');

Note the é character. Using the SQLite browser, I can insert this statement with the proper encoding.

However, if I save the above statement as a file (my.sql) and then run it on the Windows command line, I am having an encoding problem. The é in Café is garbled up.

C:\somewhere> sqlite3.exe my.db
sqlite> .read my.sql

I'm using Notepad++ to create the file in ANSI encoding. I have tried to use UTF-8 encoding but sqlite3.exe gives me a syntax error while reading the SQL file.

Is there any solution to fix this?

Upvotes: 3

Views: 811

Answers (1)

Yasushi Shoji
Yasushi Shoji

Reputation: 4274

The encoding UTF-8 in notepad++ has BOM, which sqlite3.exe does not know about. Try using UTF-8 without BOM.

Upvotes: 1

Related Questions