Re: [sqlite] UTF-8

2010-12-17 Thread Ming Lu

Hello afriza,

thanks for your quick replay. if i use the WCHAR or std'::wstring, 
should i used the _UNICODE macro in the Visual Studio Project setting?

best regards
ming

On 16.12.2010 17:34, Afriza N. Arief wrote:
 @Cory: correct.

 Fixed Code:

 HWND hWnd = /* from somewhere */;
 int nLen = GetWindowTextLength(hWnd) + 1;
 WCHAR* lpszText = (WCHAR*)malloc(nLen*sizeof(WCHAR));
 // 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(WCHAR),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

 Note:
 - You need your project to be compiled in UNICODE

 On Fri, Dec 17, 2010 at 12:24 AM, Cory Nelsonphro...@gmail.com  wrote:
 Just a quick note -- TCHAR is not always UTF-16, and
 sqlite3_bind_text16 takes a void* so it will happily take whatever you
 give it.  You should be using wchar_t directly instead of TCHAR, so an
 error can be caught when you use GetWindowText.

 ___
 sqlite-users mailing list
 sqlite-users@sqlite.org
 http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] UTF-8

2010-12-16 Thread Ming Lu
Hello everyone,

i am faceing a problem with unicode to save german umlaute in sqlite:

here ist the problem:

dev-envoriment:
Visual studio 2008
SQLite 3.6.20

i used the sqlite c/c++ interface and open a db used sqlite3_open. 
during the running of my application will the german-umlaut or other 
symbol transported into the database. i use the SQLite Manager(firefox 
plugin) to open the db and the umlaut cannot be correctly saved into the 
database(see the pic) :

- it should be ä.

my question is, how can use the sqlite c/c++ interface to save the 
unicode correctly into a sqlite database?

thanks a lot
best regards

Ming
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] UTF-8

2010-12-16 Thread Ming Lu
Hello Martin,

thank you very much for your suggestion.

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?

thanks a lot
best regards
ming

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.

 Pictures / Attachments do not make it to the list.

 Martin


 Am 16.12.2010 14:17, schrieb Ming Lu:
 Hello everyone,

 i am faceing a problem with unicode to save german umlaute in sqlite:

 here ist the problem:

 dev-envoriment:
 Visual studio 2008
 SQLite 3.6.20

 i used the sqlite c/c++ interface and open a db used sqlite3_open.
 during the running of my application will the german-umlaut or other
 symbol transported into the database. i use the SQLite Manager(firefox
 plugin) to open the db and the umlaut cannot be correctly saved into the
 database(see the pic) :

 -   it should be ä.

 my question is, how can use the sqlite c/c++ interface to save the
 unicode correctly into a sqlite database?

 thanks a lot
 best regards

 Ming
 ___
 sqlite-users mailing list
 sqlite-users@sqlite.org
 http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
 ___
 sqlite-users mailing list
 sqlite-users@sqlite.org
 http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users