Try this:

HWND hWnd = /* from somewhere */;
int nLen = GetWindowTextLength(hWnd) + 1;
TCHAR* lpszText = (TCHAR*)malloc(nLen*sizeof(TCHAR)); // std::wstring str;
str.resize(nLen);
nLen = GetWindowText(hWnd,lpszText,nLen); //
str.resize(nLen=GetWindowText(hWnd,&str[0],nLen));

sqlite3_bind_text16(stmt,1,lpszText,nLen*sizeof(TCHAR),SQLITE_TRANSIENT);
//  (.., str.data(),nLen*sizeof(std::wstring::value_type),SQLITE_TRANSIENT);
free(lpszText); // not needed for std::wstring

When you first time create the database, use sqlite3_open() to store the
data as utf8. I believe bind_text16() will convert from utf16 to utf8 for
you.

See:
- GetWindowTextLength()
http://msdn.microsoft.com/en-us/library/ms633521.aspx
- GetWindowText() http://msdn.microsoft.com/en-us/library/ms633520.aspx
- sqlite3_bind_text16() http://www.sqlite.org/c3ref/bind_blob.html


On Thu, Dec 16, 2010 at 10:51 PM, Pavel Ivanov <paiva...@gmail.com> wrote:

> > std::string strText = GetWindowsTitle(...);
> > the GetWindowsTitle occupied sometime with the umlaut.
> > so how will you do, if you want save std::string into sqlite with keeped
> > umlaut?
>
>
> Pavel
>
> On Thu, Dec 16, 2010 at 8:40 AM, Ming Lu <ming...@xenovation.com> wrote:
> > i tried again with the firefox plugin works very well with the umlaut.(i
> > update the feld with a "รค", it can been shown correctly).
> >
> > in my code:
> >
> > std::string strText = GetWindowsTitle(...);
> >
> > the GetWindowsTitle occupied sometime with the umlaut.
> >
> > so how will you do, if you want save std::string into sqlite with keeped
> > umlaut?
> >
> >
> > On 16.12.2010 14:26, Martin Engelschalk wrote:
> >> Hello Ming,
> >>
> >> sqlite does nothing to transform data between codepages, and it assumes
> >> that data you insert is passed in UTF8.
> >> However, sqlite will acept any data and store it.
> >>
> >> If the firefox plugin does not show you data correctly, then you
> >> problably did not pass correct UTF8 to sqlite. Can you check this?
> >>
> >> I just checked the firefox (0.6.5) plugin with my databases, it works
> >> correctly for me.
> >>
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to