[hyena/sqlite] [Hyena.Data.Sqlite] Null-terminate UTF8 strings



commit 555696fe417390203fb4eb20786d2ea689471101
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Nov 10 20:54:40 2010 -0600

    [Hyena.Data.Sqlite] Null-terminate UTF8 strings

 Hyena.Data.Sqlite/Hyena.Data.Sqlite/Sqlite.cs |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/Hyena.Data.Sqlite/Hyena.Data.Sqlite/Sqlite.cs b/Hyena.Data.Sqlite/Hyena.Data.Sqlite/Sqlite.cs
index 19adbbd..edd6600 100644
--- a/Hyena.Data.Sqlite/Hyena.Data.Sqlite/Sqlite.cs
+++ b/Hyena.Data.Sqlite/Hyena.Data.Sqlite/Sqlite.cs
@@ -23,7 +23,7 @@ namespace Hyena.Data.Sqlite
         public Connection (string dbPath)
         {
             DbPath = dbPath;
-            CheckError (Native.sqlite3_open (Encoding.UTF8.GetBytes (dbPath), out ptr));
+            CheckError (Native.sqlite3_open (Native.GetUtf8Bytes (dbPath), out ptr));
             if (ptr == IntPtr.Zero)
                 throw new Exception ("Unable to open connection");
 
@@ -569,5 +569,10 @@ namespace Hyena.Data.Sqlite
         {
             return System.Runtime.InteropServices.Marshal.PtrToStringUni (ptr);
         }
+
+        internal static byte [] GetUtf8Bytes (string str)
+        {
+            return Encoding.UTF8.GetBytes (str + '\0');
+        }
     }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]