Thanks Simon, problem solved with two ways
********************************************
First option:
var dbPath2 =
Path.Combine(Windows.Storage.ApplicationData.Current.RoamingFolder.Path,
"test.db");
string utf8String = String.Empty;
// Get UTF16 bytes and convert UTF16 bytes to UTF8 bytes
byte[] utf16Bytes = Encoding.Unicode.GetBytes(dbPath2);
byte[] utf8Bytes = Encoding.Convert(Encoding.Unicode,
Encoding.UTF8, utf16Bytes);
// Fill UTF8 bytes inside UTF8 string
for (int i = 0; i < utf8Bytes.Length; i++)
{
// Because char always saves 2 bytes, fill char with 0
byte[] utf8Container = new byte[2] { utf8Bytes[i], 0 };
utf8String += BitConverter.ToChar(utf8Container, 0);
}
string dbPath = utf8String;
var db = new SQLite.SQLiteConnection(dbPath)
**************************************
Second option (In Sqlite.cs comes when you add the reference)
public SQLiteConnection(string databasePath, bool
storeDateTimeAsTicks = false)
{
DatabasePath = databasePath;
Sqlite3DatabaseHandle handle;
var r = SQLite3.Open16(DatabasePath, out handle);
Handle = handle;
if (r != SQLite3.Result.OK)
{
throw SQLiteException.New(r, String.Format("Could not
open database file: {0} ({1})", DatabasePath, r));
}
_open = true;
StoreDateTimeAsTicks = storeDateTimeAsTicks;
BusyTimeout = TimeSpan.FromSeconds(0.1);
}
******************************************
However, does every developer have to write or change his code like
this? (Because, applications are worldwide and many users affected by
this problem, examples from Tim Heuer's blog:
http://timheuer.com/blog/archive/2012/05/20/using-sqlite-in-metro-style-app.aspx#65397
http://timheuer.com/blog/archive/2012/05/20/using-sqlite-in-metro-style-app.aspx#65427
http://timheuer.com/blog/archive/2012/05/20/using-sqlite-in-metro-style-app.aspx#65692
)
On Wed, Mar 13, 2013 at 3:48 PM, Simon Slavin <[email protected]> wrote:
>
> On 13 Mar 2013, at 11:45am, Ercan Özdemir <[email protected]> wrote:
>
>> I have some applications in Windows 8 store using SQLite as database.
>> I discovered that if there are any non-English character in logged on
>> username, SQLite couldn't open datase file.
>>
>> Here is my test code:
>>
>> string dbPath =
>> Path.Combine(Windows.Storage.ApplicationData.Current.RoamingFolder.Path,
>> "test.db");
>
> The value of "Windows.Storage.ApplicationData.Current.RoamingFolder.Path"
> includes the username. So if the user has non-Roman characters in their
> name, the path passed to "ne SQLite.SQLiteConnection()" will also include
> non-Roman characters in its name. I don't think "new
> SQLite.SQLiteConnection()" is handing your special characters correctly.
> This implies that dbPath contains text in a code page which is not Unicode.
>
> SQLite itself handles this by having a two ways to open a database file: one
> which expects UTF-8 and the other expects UTF-16. I don't know which one
> "new SQLite.SQLiteConnection()" calls. But you should be able to convert
> your dbPath value to UTF-8 or UTF-16 using some Operating system call, and
> pass the converted version of the path.
>
> Simon
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users