Okay. I worked out a solution, but I am still unsure of why it fixes the
problem. Or rather, I know why it works, but it still doesn't explain why the
basic_string::c_str() call did not work. My only guess is that
basic_string::c_str() doesn't really provide a pointer to a null-terminated
c-style string, but a facsimile of one that SQLite doesn't like.
Here's that statement from my code again with the mods included that make the
code work:
char *surbuf[100];
memset(surbuf, 0, 100);
strcpy(surbuf, CurrentName -> second.GetSurName().c_str());
idx = -1;
idx = sqlite3_bind_parameter_index(ResultStmt, ":sur");
sqlite3_bind_text(ResultStmt, idx, surbuf, strlen(surbuf),
SQLITE_STATIC);
BTW, I was using the .output command in the SQLITE3 shell to attempt piping my
output to a file. The command looked like this:
.output c:\sqlite.txt
Select * from Names;
When I went to the root of C: I did not find the file. So I removed the path
from the filename and later found it in the SQLLite directory from which I was
running the shell.
R,
John
> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> On Behalf Of Pavel Ivanov
> Sent: Friday, December 17, 2010 4:44 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] Troubleshooting...
>
> > So you can see that when I add the hard-coded data, everything looks fine
> > in the
> results of the select statement, which leads me to believe that the problem
> is not
> confusion between UTF8 and UTF16 output.
>
> Your hardcoded data has only characters from ASCII set which don't
> differ from the same in UTF-8. Besides SQLite API and command line
> utility don't check your strings to be valid UTF-8. SQLite API puts
> into database whatever you give to it, command line utility throws to
> stdout whatever it finds in the database (so my guess could be wrong
> and your input strings could be not in UTF-8 but in some other
> encoding). It's totally developer's responsibility to make sure that
> encoding put into database is the same as is expected when it's
> retrieved from database.
>
> > I could not figure out how to pipe my info to a file
>
> One of possible solutions is to use .output command in the sqlite3
> utility (you can use .help command to see everything that is available
> to you there) or to provide your sql statement as last argument when
> you start sqlite3 utility and use standard redirection like this:
>
> sqlite3 database.db "select * from mytable" >output.txt
>
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users