Search code examples
c#.netsqliteutf-8windows-store-apps

How to create SQLite database in UTF-8 encoding


I'm developing a Windows Store app (C#) using a SQLite database.

Issue

If I have a special chars in a row like "qwerôty", when my app retrieve this value, the string object contains "qwerty" (without this special char).

Database creation

I create my database with the sqlite3 utility, then I write all my queries (create table, insert into...) in a file (UTF-8 encoded) and I copy&paste all the queries in the command prompt of sqlite3.

When I do a select * from table I see "qwerôty", but once in my app, the string does'nt contains the "ô".

In-app code

Here is how I retrieve my data from the SQLite database :

private SQLiteAsyncConnection conn = new SQLiteAsyncConnection(DbPath);
return await conn.Table<BusinessObject>().ToListAsync();

The string property is within the BusinessObject object

My guess

I think the sqlite file that I create with sqlite3 is not encoded in UTF-8. When I open it with the Windows built-in notepad and I do a "sav as", the selected encoding is ANSI. But I can't find how to create the database encoded in UTF-8.

If you have any idea of what is my issue, thanks in advance.

Rafi


Solution

  • The issue came from Notepad as Paparazzi stated