问题
I tried to create a sqlite database from a csv file. I did it as it is said in this page : using your own sqlite db in android and this : import csv to sqlite
but the problem is when the table contains data in farsi/arabic language. sqlite shows that character as "_". what should I do?
PS. I want to use this DB in an android project.
edit: I import csv to sqlite using this code:
CREATE TABLE "android_metadata"("locale" TEXT DEFAULT 'en_US');
CREATE TABLE "addresses"(_id integer PRIMARY KEY,
nametext, meaning text);
.separator ","
.import test.csv mydb
回答1:
sqlite supports UTF-8, UTF-16 and this is quite enough to store arabic or persian.
Most probably you get "_" because the import tool expects different charset than the charset of your original file.
回答2:
Persian/Farsi is not supported in Android up to version 4.0, but there are some things that might help you listed here.
I also came across this stackoverflow question about Persian numbers in SQL, though I'm not sure that will help at all.
I found a similar question to yours: C# - Does Sqlite database support persian/arabic encoding? and this seems to give an unfortunately negative answer:
In short: No.
SQLite support only a very, very limited number of encodings: UTF-8 and UTF-16 (multiple varieties).
Fortunately, UTF-8 is perfectly suitable for expressing Arabic or Persian, or any other language (including Klingon, should the fancy grab you).
It is posible, of course, that some other part of your toolchain is bungling the encoding, check the documentation for the C#.net SQLite wrapper, and your Forms code.
来源:https://stackoverflow.com/questions/13862930/sqlite-database-in-persian-language