Hi Christian, ----- Original Message ----- From: "Christian Smith" <[EMAIL PROTECTED]> To: <sqlite-users@sqlite.org> Sent: Thursday, April 20, 2006 11:16 AM Subject: Re: [sqlite] Using sqlite3_open or sqlite3_open16?
> On Thu, 20 Apr 2006, DBTools Software wrote: > > >Hi, > > > >I have an application that needs to open a database in the users's personal > >folder. I noticed that in some circunstances the sqlite3_open fail as the > >filename is in UTF16 format. I don't know that in advance so I could open > >the db with sqlite3_open16. > > > >The question is: > > > >Is it safe to always use the UTF16 functions independent of the > >localization? What I mean is can I use the functions sqlite3_xxx16 instead > >of sqlite3_xxx for all cases? > > > Your data should always be in UTF-16 to use sqlite3_xxx16, else you'll > incur the cost of transforming your date to/from UTF-8. > > If most of your data is UTF-8 or ASCII, use the regular UTF-8 functions. > If your filename is UTF-16, just convert it to UTF-8 (it's a relatively > simple, unambiguous transformation) and use sqlite3_open. Thanks for the info. I did have found in the manual that UTF16 is converted to UTF8 on Windows environments. But one little question: How would one know if the filename is in UTF8 or UTF16? You see, my little application is installed in PC's all around the world. I don't know in advance if the filename is UTF8 or UTF16. I noticed that always using UTF16 to open the database can lead to an exception in filenames with UTF8. I have used the following workaround: First I try to open the db with sqlite3_open(). If it fails then I try to open it with sqlite3_open16(). One of them should work as expected (of course considering that everything else is ok). Is there another or easier way. Thanks. COS