0

i am facing problems while reading data from SQl Lite Database against arabic data that i have stored. Arabic text is saved correctly in my Db. I am using following code.

if(language == "arabic"){
    //alert(value);
    db.transaction(function(tx) {tx.executeSql('SELECT *  FROM BRANDOFFERS WHERE brandId IN (SELECT id FROM BRANDS WHERE nameArabic="'+value+'") ', [], fillDiscountType, errorCB);}, errorCB);
}else{
    db.transaction(function(tx) {tx.executeSql('SELECT *  FROM BRANDOFFERS WHERE brandId IN (SELECT id FROM BRANDS WHERE name="'+value+'") ', [], fillDiscountType, errorCB);}, errorCB);

In case of arabic it not fetching any result but against english i am getting correct results. Moreover, I tried to display the arabic text from sqllite DB, it is showing right. But, i don't why it can't able to search with the arabic text.In

Nomiluks
  • 2,052
  • 5
  • 31
  • 53
  • are u testing in android ? – ULLAS MOHAN.V Mar 31 '14 at 12:54
  • can u test this : http://blog.gabemastey.com/post/42979676803/arabic-fonts-on-ios-android-webkit-for-phonegap-app – ULLAS MOHAN.V Mar 31 '14 at 12:56
  • yes am doing it in android – Nomiluks Mar 31 '14 at 13:03
  • Could this possibly be something similar to [persian/arabic search in sqlite android gives bad result](http://stackoverflow.com/questions/22295771/persian-arabic-search-in-sqlite-android-gives-bad-result)? Are you sure that both strings are using the same Unicode characters? – CL. Mar 31 '14 at 15:27

1 Answers1

0

I think i figured it out. I used the following piece of code

var getServerAtabicText = brands[i].nameArabic;  //Arabic text
var decodedArabicText = $('<div/>').html(getServerAtabicText).text();

before saving arabic text into SQL lite DB. Then i simply run the same code:

if(language == "arabic"){
//alert(value);
db.transaction(function(tx) {tx.executeSql('SELECT *  FROM BRANDOFFERS WHERE brandId IN (SELECT id FROM BRANDS WHERE nameArabic="'+value+'") ', [], fillDiscountType, errorCB);}, errorCB);
}else{
db.transaction(function(tx) {tx.executeSql('SELECT *  FROM BRANDOFFERS WHERE brandId IN (SELECT id FROM BRANDS WHERE name="'+value+'") ', [], fillDiscountType, errorCB);}, errorCB);

for query my data and it works (:

Nomiluks
  • 2,052
  • 5
  • 31
  • 53