Igor: Thanks for your answer; let me see if I understood correctly the process:
[1] Read the actual textual data with sqlite3_column_blob() [2] Assuming the system code page matches the one used when the data was originally inserted, convert with mbstowcs() [3] (Doubt) The result can be directly written with sqlite3_bind_text() -I want store in UTF-8- OR must I write the result with sqlite3_bind_text16()? Them, the data is stored as UTF-16? or as UTF-8? [4] Afterward once converted the dBase and in regular use: [4-1a] Read with sqlite3_column_text() [4-1b] convert with WideCharToMultiByte(CP_UTF8) [4-1c] Use the result with Win32 api -SetTex()- OR? [4-2a] Read with sqlite3_column_text16() [4-2b] No convertion needed. [4-2c] Use the result ... The opposite to go from GetText() to dBase. -- A.J.Millan ----- Original Message ----- From: "Igor Tandetnik" <itandet...@mvps.org> To: <sqlite-users@sqlite.org> Sent: Thursday, October 29, 2009 12:51 PM Subject: Re: [sqlite] Some clarification needed about Unicode > A.J.Millan wrote: >> Really, here you touched tangentially the core of my question. Besides >> all >> those great theories, at last I have UTF-8 encoded data in a dBase, and >> the >> UCS-2 encoded data of the MS Win32 API (w_chars in muy Cpp app). The >> question is: What is the concrete way to and from that w_chars to the >> UTF-8 >> that need SQLite? (my guess is use UTF-8 to the stored data) Can I use >> wcstombs() or even WideCharToMultiByte()? -this last seem a nightmare to >> me-. > > Not wcstombs - it uses system default codepage, and that is never UTF-8. > You can use WideCharToMultiByte(CP_UTF8) - I don't quite see why you find > it so offensive. You can use a third-party library if you are so inclined, > e.g. ICU. You can roll your own - a conversion between UTF-8 and UTF-16 is > pretty straightforward. Or, you can simply use SQLite's 16-bit API (e.g. > sqlite3_bind_text16) and have it convert to UTF-8 for you automatically. > >> Really, preventing future possible problems, my textual data was stored >> as >> blob. The idea is rebuild converting from 8 bits ASCII to UTF-8. Then the >> question: can be done with mbstowcs() prior to using sqlite3_bind_text()? > > You probably mean sqlite3_bind_text16. Yes, you can use mbstowcs, assuming > your system code page matches the one used when the data was originally > inserted. > > Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users