5

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
shohreh
  • 526
  • 9
  • 20

2 Answers2

3

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.

Andriy B
  • 724
  • 5
  • 19
1

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.

Community
  • 1
  • 1
breadbin
  • 584
  • 1
  • 11
  • 19
  • there is no problem with android. the problem is when i convert csv to sqlite .db file. after importing the csv file, persian characters change to "_" – shohreh Dec 13 '12 at 15:53
  • Right, but according to the quote I listed above, from the third link, Sqlite doesn't support persion/arabic encoding, so you may need to do some parsing/conversion on the CSV file to change the persion/arabic characters to something that SQLite can handle. – breadbin Dec 13 '12 at 15:55