Chartreed
Chartreed

Reputation: 13

Select japanese character from sqlite database

I created a database from the Edict files with java and i used for that SQLite.

SQLite by default encode the string in UTF-8

Here is a sample of the database: sample

If i do

Select* FROM entry 

In Java i get the japanese words in their "correct" form (graphical representation at least).

But if i try and do.

Select * FROM entry WHERE wordJP LIKE '食べる'"

I obviously get nothing. That makes it very hard to find the definition of a word.

Can someone explain why this is occuring, and how to solve it ? I kind of understand that it is a problem of encoding but i don't understand where it happens and why.

Upvotes: 0

Views: 1092

Answers (2)

Chartreed
Chartreed

Reputation: 13

So i managed to solve this:

  • Using iconv from linux to encode the file from EUC-JP to UTF-8
  • Setting SQLITE to UTF-8
  • Java is supposed to be natively in UTF-8, but eclipse put it by default on some ISO-xxx codage, so you need to change that by right-clicking on your project > properties > text file encoding > other (scroll the list)

Upvotes: 1

P-Gn
P-Gn

Reputation: 24651

From your link,

[EDICT] is a plain text document in EUC-JP coding.

If you query strings are encoded in UTF-8, matching will fail.

You should probably try to convert the database into UTF-8 when you fill-in your sqlite database.

Upvotes: 0

Related Questions