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

Discussion in 'Questions (Windows Mobile)' started by dennychuang, May 21, 2008.

  1. dennychuang

    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!
     
  2. dennychuang

    dennychuang Member Licensed User

    how to display chinese characters from sqlite3

    [​IMG]

    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:
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Changing the font type of controls is done with FormLib.ChangeFont.
    The SQL engine uses UTF8 which supports Chinese. You should use this encoding when you store the data with an external tool.
     
  4. dennychuang

    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: May 22, 2008
  5. Erel

    Erel Administrator Staff Member Licensed User

    Please try the following code (you may need to change the table's font on the device):
    Code:
    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.
     
  6. dennychuang

    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:
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice