how to display chinese characters (High-ASCII, double-byte) using sqlite3

dennychuang

Member
Licensed User
Howdy,

I'm new to B4P and I love this IDE tool. Chinese characters works with all the controls (textbox, label etc...), but when I display data using the SQL Controls the chinese characters disppeared and turned to square boxes.
My data stores in the .sl3 format (created using the sqlite3.exe).

I have downloaded .net cf (chinese version) V2 and I'm wondering if I need to have a different SQLdesktop.dll with double-byte character support? where can I find it? Or do I need to set the default font type to chinese fonts for the SQL Controls?

Attached is my screen capture.

:sign0085:
Please give me a direction... Thanks!
 

dennychuang

Member
Licensed User
how to display chinese characters from sqlite3

b4p_support_chinese.jpg


Anyone know what do I need to do to make chinese character display on the SQL Controls? how do I Set font type on the controls?

:sign0085:
 

dennychuang

Member
Licensed User
using Formlib

Hi Erel,

I have add the Formlib to my code but the chinese characters in sqlite still couldn't display correctly.
here is a what I have done.

Sub App_Start
Form1.Show
Formlib.New1("Form1",B4PObject(1))
Formlib.ChangeFont("ListBox3","simsun")
Formlib.ChangeFont("Table1","simsun")

...

The fonts are now changed to simsun but it's still display as square boxes...
Help!

Here is my sqlite data and code.
http://www.ecdiy.com.tw/b4p/sqlite_chinese.zip
---
Are there any vietnamese b4p users? I have a project to develop a free vietnamese <-> chinese<-> english dictionary for WinCE devices... let me know if any of you are interested.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please try the following code (you may need to change the table's font on the device):
B4X:
Sub Globals
    'Declare the global variables here.

End Sub

Sub App_Start
    Form1.Show
    con.New1
    Con.Open("Data Source = " & AppPath & "\test.db")
    cmd.New1("",con.Value)
    InsertData
    cmd.CommandText = "SELECT * from table1"
    cmd.ExecuteTable("table1",500)
End Sub

Sub InsertData
    cmd.CommandText = "CREATE TABLE IF NOT EXISTS table1 ('col1' text)"
    cmd.ExecuteNonQuery
    cmd.CommandText = "INSERT INTO table1 VALUES('新細明體')"
    cmd.ExecuteNonQuery
End Sub


This code will create a new database and add some Chinese text.
 

dennychuang

Member
Licensed User
Chinese displaying Problem Solved!

Hi Erel,

Thanks for your helpful solutions! I have now find out my problem is caused by incompatible chinese default coding. SQLite3 insert statements cannot be inserted directly under DOS command lines. It must be inserted by running the SQLite GUI or by B4P's coding.

cmd.CommandText = "INSERT INTO table1 VALUES('新細明體')"

Well, thanks again for the prompt reply!

B4P is great!!!:sign0060:
 
Top