I have a problem displaying the swedish characters "åäö", read from my database, in my android application.
I have created the database using the sqlite3 command-p开发者_JS百科rompt shell and the characters display correctly there. Also "åäö" which are not read from the database display correctly in the application.
I have searched everywhere and I can't think of a solution. I've tryed different encodings on my database text but it doesn't seem to work.
You do not mention whether you are using javaScript/PhoneGap or Java to communicate with Sqlite in Android. // Yes, I know PhoneGap is using Java too.
If you are using pure Java, you better check out the following link as there have been some updates to how Java handles utf-8 encoding. Effected versions are: JDK7, Open JDK 6, JDK 6 update 1, JDK5.0u17, and 1.4.2_19. As far as I understand, the Java version in Android follows the new regime.
Reference: http://blogs.oracle.com/CoreJavaTechTips/entry/the_overhaul_of_java_utf
You mention that you have tried different encodings for the database, however you do not mention whether or not you have done this through Android or from cmd/gui on your desktop.
Anyhow, I will give you some pointers. You probably know all of this already, but I’ll include it anyway.
HTML
As Tapirboy mentioned in his comment, make sure you have set the character encoding for whatever view you are using. For HTML5 you can do that like this:
<meta charset="UTF-8">
CSS
You should also make sure that you’ve got, and are using, an utf-8 compatible font in Android. The default DroidSans.ttf is capable of drawing utf-8 characters for all western languages.
In CSS the font-family should be set to “Droid Sans” not “droidsans”.
SQLITE
Check character encoding in sqlite:
PRAGMA encoding;
Setting character encoding in sqlite:
PRAGMA encoding = "UTF-8";
JavaScript
<script type="text/javascript" charset="utf-8">
</script>
As you, I’m developing Android applications in other languages than English. In my case it’s Norwegian and Thai.
I have set the character encoding to utf-8 for Sqlite, webview and javaScript, using PhoneGap 1.1.0 and jQuery 1.6.4, and have no problems displaying Norwegian and Thai characters in Android Emulator.
Hälsning från en norrbagge
精彩评论