2013-01-04 15 views
-1

我有一個列表視圖,它由來自SQLite數據庫的數據填充。我的一個領域是一個具有unicode特徵的標記,可以是整圈:\ u25cf或者打開的圈:\ u25cb。當我在文本字段中使用硬編碼字符串時,這兩個字符都能正確顯示。但是,在我的listView中,我看到的是文本編碼而不是字符。從SQLite數據庫顯示一個Unicode字符

有誰知道爲什麼這是...以及如何讓unicode字符顯示?

謝謝。

更新:

插入碼是

private void loadRecords() throws IOException { 
     final Resources resources = mContext.getResources(); 
     InputStream inputStream = resources.openRawResource(R.raw.records); 
     BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); 
     try { 
      String line; 
      while ((line = reader.readLine()) != null) { 
       String[] strings = TextUtils.split(line, ","); 
       if (strings.length <2) continue; 
       long id = addRecord(strings[0].trim(),strings[1].trim(),strings[2].trim(),strings[3].trim(), 
         strings[4].trim(),strings[5].trim(),strings[6].trim()); 
      } 
     } finally { 
      reader.close(); 
     } 
    } 

與所述資源是與一個線是例如csv文件

primaryKey,name,surname,address,phone,email,\u25CB 
+0

因爲您沒有在數據庫中正確插入它。 – njzk2

+0

你是什麼意思,你是「看到文字編碼,而不是字符」?它究竟如何顯示? –

+0

我的意思是,lisView中的元素顯示爲「\ u25CB」,而不是顯示一個空心圓。 – user1791710

回答

0

在您的文本文件中,\u25CB是六個字符。

要正確使用Unicode字符,把它們直接進入文件:

primaryKey,name,surname,address,phone,email,● 

但是,你必須確保.csv文件具有相同的編碼爲您InputStreamReader使用(設置的第二個參數它的構造函數)。

+0

謝謝 - 我會試試。 – user1791710