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

In this forum you can discuss database related issues which can be wxWidgets related, but also generic in nature.
Post Reply
dode
Earned a small fee
Earned a small fee
Posts: 23
Joined: Sun Mar 06, 2016 10:22 am

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

Post 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"
Last edited by doublemax on Sun Mar 06, 2016 10:48 am, edited 1 time in total.
Reason: Added code tags
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post by doublemax »

Does it also happen if the update string contains only ASCII characters?
Use the source, Luke!
dode
Earned a small fee
Earned a small fee
Posts: 23
Joined: Sun Mar 06, 2016 10:22 am

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

Post by dode »

No otherwise the Update semms to be ok
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post 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?
Use the source, Luke!
dode
Earned a small fee
Earned a small fee
Posts: 23
Joined: Sun Mar 06, 2016 10:22 am

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

Post 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
dode
Earned a small fee
Earned a small fee
Posts: 23
Joined: Sun Mar 06, 2016 10:22 am

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

Post by dode »

Just to a confirmation of reading :
Attachments
2016-03-06-123232_1366x768_scrot.png
dode
Earned a small fee
Earned a small fee
Posts: 23
Joined: Sun Mar 06, 2016 10:22 am

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

Post 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.
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post 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();
}
Use the source, Luke!
dode
Earned a small fee
Earned a small fee
Posts: 23
Joined: Sun Mar 06, 2016 10:22 am

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

Post by dode »

You the man.
Simply works like a beauty.
Thanks a lot for your prompt help.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

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

Post by ONEEYEMAN »

Hi,
Which suggestion from doublemax worked - first or second?

This might be helpful to other people....

Thank you.
dode
Earned a small fee
Earned a small fee
Posts: 23
Joined: Sun Mar 06, 2016 10:22 am

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

Post by dode »

First Version was my original code, the second is the working one Bind(...)
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post 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
Use the source, Luke!
Post Reply