从 SQLite & 中选择阿拉伯语数据时编码结果不好安卓 [英] Bad result with encoding when Selecting arabic data from SQLite & android

查看:13
本文介绍了从 SQLite & 中选择阿拉伯语数据时编码结果不好安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 SQLite 和 android 时遇到问题,我正在尝试从数据库中选择阿拉伯语数据,该数据库由 android 外部的数据填充,然后我将其推送到 android 模拟器..英文文本显示正常,但阿拉伯文本显示错误

I have a problem with SQLite and android, I`m trying to select arabic data from the db, the db filled by the data outside android and i push it to android emulator.. the english text appears normaly but the arabic text appear in wrong way

文本看起来像这个 img

the text appears like this img

请帮帮我

推荐答案

我用通过代码创建的随机文本检查了阿拉伯语数据库:

I checked with Arabic database with random text created via code:

db = openOrCreateDatabase("dictionary", MODE_PRIVATE, null);
db.execSQL("CREATE TABLE IF NOT EXISTS LIST(wlist varchar);");
db.execSQL("INSERT INTO LIST VALUES('صبالخير');"); 
db.execSQL("INSERT INTO LIST VALUES('صبا لخير');");  

然后我使用以下带有光标的查询从数据库中动态选择文本:

Then I used following query with cursor to dynamically select text from database:

String q = "SELECT * FROM LIST";
Cursor c = db.rawQuery(q, null);
if(c.getCount() == 0)
  {
    setSuggestions(list, true, true);
  }
else{
  int i=0;
  c.moveToFirst();
     do {
         String cm = c.getString(c.getColumnIndex("wlist")); 
                      list.add(cm);
                      i++;
        } while (c.moveToNext() && i<30);      

结果如下:


显示阿拉伯文字.因此,如果阿拉伯数据的格式正确,请使用 SQLite 数据库浏览器检查您现有的数据库.


Arabic text is shown. So, check your existing database with a SQLite Database Browser if Arabic data is in correct form there.

这篇关于从 SQLite &amp; 中选择阿拉伯语数据时编码结果不好安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆