Pelles C forum

C language => Expert questions => Topic started by: Grincheux on June 15, 2020, 06:48:05 pm

Title: Import SQLite
Post by: Grincheux on June 15, 2020, 06:48:05 pm
I have a txt file that I want to import to create a SQLite database.
The C coding is good, import works except one thing:
I am French, so ther are accents in words.
When looking with Notepad++ the text file is in ANSI and would have to be in UTF-8.
How to convert, I tried with WideCharToMultiByte and with code page 28605(iso-8859-15
ISO 8859-15 Latin 9), this not correct for sqlite. When I import the txt file manually using "DB Broowser for SQLIte", it is good. Here is my coding:
Code: [Select]
                        "INSERT INTO Distance VALUES(%d%7.7d,%d,%d,%d,%f,%f,\"%w\",%d,%d,%d,%f,%f,\"%w\",%f);",
                        dDistance[_j]) ;

                  sqlite3_exec(hParser,_szTmp,0,0,NULL) ;

The txt file can be found at ( and the databse is at (

Please help me!!!
Title: Re: Import SQLite
Post by: Grincheux on June 15, 2020, 07:33:56 pm
Finaly the answer is at (
Title: Re: Import SQLite
Post by: John Z on June 16, 2020, 11:23:41 am
Very useful code link. Especially useful is the CheckUTF8 routine.  Thanks!

If you would like to use the built in functions I believe it is a two step process.
First you use MultiByteToWideChar to get a Unicode string then you pass that to
WideCharToMultiByte using CP_UTF8 to get your final string.

Hope this helps,