Re: CDatabase and UNICODE problem
- From: "bitkidoku" <b.evrim@xxxxxxxxx>
- Date: 22 Dec 2006 06:56:42 -0800
Thank you for quick answer.
David Wilkinson wrote:
Can you store UTF-8 strings in the database? You can use
WideCharToMultiByte() to convert from "Unicode" to UTF-8.
I think I can store UTF-8 strings in the database because it is a
simple access file (.mdb).
Let me explain my problem a little deeper.
I was using this piece of code to send queries (altered to be more
clear):
sSQL = "INSERT statement with unicode characters in it like öçgs";
myDatabase.ExecuteSQL(sSQL);
After inserting some rows to DB, I looked at what is inserted, and all
the special characters are converted to their equivalents like ö->o
ç->c g->g s->s
Then I traced into ExecuteSQL() method and saw this (in dbcore.cpp):
AFX_ODBC_CALL(::SQLExecDirect(hstmt, (UCHAR*)T2A((LPTSTR)lpszSQL),
SQL_NTS));
Any unicode string I provide is converted to it's ansi equivalent via
T2A() macro. I thought that I could do nothing about it but I tried to
use WideCharToMultiByte() after you adviced me to do so.
Now my code became this:
sSQL = "INSERT statement with unicode characters in it like öçgs";
Bytes = new char[sSQL.GetLength() + 1];
WideCharToMultiByte(CP_UTF8,0,sSQL,-1,Bytes,sSQL.GetLength()+
1,NULL,NULL);
myDatabase.ExecuteSQL((LPCTSTR)Bytes);
delete [] Bytes;
But when I try to execute it throws an exception, m_strError of
exception is {"COUNT field incorrect "}.
I have no clues what to do so, I need help very badly.
Thank you for your answers.
.
- Follow-Ups:
- Re: CDatabase and UNICODE problem
- From: bitkidoku
- Re: CDatabase and UNICODE problem
- References:
- CDatabase and UNICODE problem
- From: bitkidoku
- Re: CDatabase and UNICODE problem
- From: David Wilkinson
- CDatabase and UNICODE problem
- Prev by Date: Version of Visual Studio
- Next by Date: Re: CDatabase and UNICODE problem
- Previous by thread: Re: CDatabase and UNICODE problem
- Next by thread: Re: CDatabase and UNICODE problem
- Index(es):
Relevant Pages
|