Page 1 of 1

unicode shows problem on UBUNTU 15.10 with wxwidgets 3.0.2 and libwxsqlite3-3.0-dev_3.2.1~dfsg1-1build1_amd64.deb

Posted: Sun Mar 06, 2016 10:30 am
by dode

Code: Select all

wxSQLite3ResultSet objQRY;
    //wxString utf8Val = wxString::FromUTF8(val.ToStdString().c_str(), val.length());
    //wxString utf8Val1 = val.mb_str(wxConvUTF8);

    const char *test = "Hebrew שלום -- Japanese (日本語)";
    wxString tmp = wxConvUTF8.cMB2WC( test );

    wxString sql = wxString::Format(wxT("UPDATE %s SET %s = '%s' WHERE id=%d;"), tableName, column, /*val*/tmp, rowID);

    try
    {
        objQRY = m_db.ExecuteQuery(ToUTF8(sql));
    }
    catch (wxSQLite3Exception& ex)
    {
       postDBErrorMessage("updateRowInTable", sql, ex);
    }
The Result is not clear ...
"Error code: 0
Extended error code: 0
Error string: not an error
From sql: UPDATE test SET TEST2 = 'Hebrew שלום -- Japanese (日本語)' WHERE id=3;
In proc: updateRowInTable
Mssg: not an error[0]: not an error"

Re: unicode shows problem on UBUNTU 15.10 with wxwidgets 3.0.2 and libwxsqlite3-3.0-dev_3.2.1~dfsg1-1build1_amd64.deb

Posted: Sun Mar 06, 2016 10:55 am
by doublemax
Does it also happen if the update string contains only ASCII characters?

Re: unicode shows problem on UBUNTU 15.10 with wxwidgets 3.0.2 and libwxsqlite3-3.0-dev_3.2.1~dfsg1-1build1_amd64.deb

Posted: Sun Mar 06, 2016 11:00 am
by dode
No otherwise the Update semms to be ok

Re: unicode shows problem on UBUNTU 15.10 with wxwidgets 3.0.2 and libwxsqlite3-3.0-dev_3.2.1~dfsg1-1build1_amd64.deb

Posted: Sun Mar 06, 2016 11:16 am
by doublemax
Just to be clear:
When using ASCII chars, the update works and you get no exception.

When using non-ASCII chars, the update works, too, but you get an exception that shows no error?

Re: unicode shows problem on UBUNTU 15.10 with wxwidgets 3.0.2 and libwxsqlite3-3.0-dev_3.2.1~dfsg1-1build1_amd64.deb

Posted: Sun Mar 06, 2016 11:29 am
by dode
Exactly.

By the way it is the same situation with insert hust the same as with update so at least the Problem is consistent.
Oh and another thing reading unicode text from table is also ok.

Kind Regards

Re: unicode shows problem on UBUNTU 15.10 with wxwidgets 3.0.2 and libwxsqlite3-3.0-dev_3.2.1~dfsg1-1build1_amd64.deb

Posted: Sun Mar 06, 2016 11:34 am
by dode
Just to a confirmation of reading :

Re: unicode shows problem on UBUNTU 15.10 with wxwidgets 3.0.2 and libwxsqlite3-3.0-dev_3.2.1~dfsg1-1build1_amd64.deb

Posted: Sun Mar 06, 2016 11:46 am
by dode
I am sorry i got you question wrong.

Unicode Update does not work and and unclear exception is thrown.
ASCII Update works with no exception.

Again sorry for my misunderstanding.

Re: unicode shows problem on UBUNTU 15.10 with wxwidgets 3.0.2 and libwxsqlite3-3.0-dev_3.2.1~dfsg1-1build1_amd64.deb

Posted: Sun Mar 06, 2016 12:50 pm
by doublemax
I don't think the error is inside wxSQLite3.

Can you try these two alternatives?

Code: Select all

wxString tmp( wxT("Hebrew שלום -- Japanese (日本語)") );
wxString sql = wxString::Format(wxT("UPDATE %s SET %s = '%s' WHERE id=%d;"), tableName, column, tmp, rowID);

try
{
    m_db.ExecuteUpdate(sql);
}

Code: Select all

wxString tmp( wxT("Hebrew שלום -- Japanese (日本語)") );
try
{
  wxString sql;
  sql.Printf( "UPDATE %s SET %s=? WHERE id=?;", tableName, column );
  wxSQLite3Statement stmt = m_db.PrepareStatement(sql);
  stmt.Bind(1, tmp);
  stmt.Bind(2, rowID);
  stmt.ExecuteUpdate();
}

Re: unicode shows problem on UBUNTU 15.10 with wxwidgets 3.0.2 and libwxsqlite3-3.0-dev_3.2.1~dfsg1-1build1_amd64.deb

Posted: Sun Mar 06, 2016 1:43 pm
by dode
You the man.
Simply works like a beauty.
Thanks a lot for your prompt help.

Re: unicode shows problem on UBUNTU 15.10 with wxwidgets 3.0.2 and libwxsqlite3-3.0-dev_3.2.1~dfsg1-1build1_amd64.deb

Posted: Tue Mar 08, 2016 4:05 pm
by ONEEYEMAN
Hi,
Which suggestion from doublemax worked - first or second?

This might be helpful to other people....

Thank you.

Re: unicode shows problem on UBUNTU 15.10 with wxwidgets 3.0.2 and libwxsqlite3-3.0-dev_3.2.1~dfsg1-1build1_amd64.deb

Posted: Tue Mar 08, 2016 10:21 pm
by dode
First Version was my original code, the second is the working one Bind(...)

Re: unicode shows problem on UBUNTU 15.10 with wxwidgets 3.0.2 and libwxsqlite3-3.0-dev_3.2.1~dfsg1-1build1_amd64.deb

Posted: Tue Mar 08, 2016 10:46 pm
by doublemax
First Version was my original code, the second is the working one Bind(...)
Just for the record, the first version i posted has three differences:

a) Use of wxT() around string literal as it's not 100% clear if the utf8-conversion in the original code is really the right thing to do

b) Use of ExecuteUpdate instead of ExecuteQuery

c) Don't convert string parameters to UTF8, wxSQLite takes wxString parameters and does the UTF8 conversion itself