sqlite encoding android

2019-07-27 04:49发布

问题:

I have an encoding problem in my database. This database is first imported form another app (written in .NET so microsoft app). So I get an .sql file and then I download it and run it in myphp admin and there I can see the varchars are in utf8.

Then I use this (WONDERFUL by the way) script to create a sqlite database AUTOMATICALLY:

https://gist.github.com/943776

Then I have my DB file and I put it in the assets folder of my app using basically this technique: http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

to use the DB and not to create a new one.

Well everything works perfectly fine the only thing is my apopp is in spanish and the coding is not quite right for letters like è, é, ª etc.... I have checked with PRAGMA encoding;

but the encodign if utf-8, what do you advise me to do??? I mean a part from rewrtiging the DB???

Thanks a lot

回答1:

Android sqlite uses UTF-8 by default. And may only use UTF-8 and UTF-16. Did you check to init your Strings retrieved from sqlite like this:

new String(row.getString().getBytes(), "UTF-8")

You may also check the other options with pragma.



回答2:

I found that SQLite Database browser 2.0 only shows Western (ISO Latin 1) correctly when importing a csv made in Numbers