I think that I resolved problems with DatabaseStringConverter class. Here are two functions which do the job and I think that they are compatibile with unicode build too.
Code: Select all
wxString ConvertToUTF8(wxString value)
wxString str(value.wc_str(*wxConvCurrent), wxConvUTF8);
wxString ConvertFromUTF8(wxString value)
wxString str(value.wc_str(wxConvUTF8), *wxConvCurrent);
I think that we don't need DatabaseStringConverter class at all. And there is no need for other class to derive from it. We can use them as standalone. Or maybe not. I don't know. Opinion?
So what's next?
On every place where database is especting char parameter (sql command or parameter in prepared statement) we have to:
- 1. convert it with ConvertToUTF8 function and
2. procede it with wxString::c_str() to database api function.
- 1. convert it to op.sys. locale with ConvertFromUTF8 function and
2. return the new string value
I noticed that now in prepared statement there is no any conversion. Why? We have to fix this too on the way above.
And I have one question/suggestion. There are two RunQuery() and RunQueryWithResult() functions. One in DatabaseLayer class and one in PreparedStatement. I think that this is a little bit confusing. Maybe we should unique it somehow. We should separate transactions, statements and database like in IBPP. I admit that I'm under an impact of IBPP library and that's because I'm using it for about a year, so sorry if I mention it a lot.
All the best,