Permalink
Browse files

Changed BindText to use bind_test16 with CharSet.Unicode to support W…

…indows
  • Loading branch information...
1 parent a97659e commit e7f03cb0be808a03bb8e2682b4dd3aa8c7084e0a @praeclarum praeclarum committed Mar 19, 2012
Showing with 49 additions and 1 deletion.
  1. +1 −1 src/SQLite.cs
  2. +1 −0 tests/SQLite.Tests.csproj
  3. +47 −0 tests/UnicodeTest.cs
View
2 src/SQLite.cs
@@ -1893,7 +1893,7 @@ public static string GetErrmsg (IntPtr db)
[DllImport("sqlite3", EntryPoint = "sqlite3_bind_double", CallingConvention=CallingConvention.Cdecl)]
public static extern int BindDouble (IntPtr stmt, int index, double val);
- [DllImport("sqlite3", EntryPoint = "sqlite3_bind_text", CallingConvention=CallingConvention.Cdecl)]
+ [DllImport("sqlite3", EntryPoint = "sqlite3_bind_text16", CallingConvention=CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
public static extern int BindText (IntPtr stmt, int index, string val, int n, IntPtr free);
[DllImport("sqlite3", EntryPoint = "sqlite3_bind_blob", CallingConvention=CallingConvention.Cdecl)]
View
1 tests/SQLite.Tests.csproj
@@ -49,5 +49,6 @@
<Compile Include="LinqTest.cs" />
<Compile Include="TestDb.cs" />
<Compile Include="InheritanceTest.cs" />
+ <Compile Include="UnicodeTest.cs" />
</ItemGroup>
</Project>
View
47 tests/UnicodeTest.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Linq;
+using NUnit.Framework;
+
+namespace SQLite.Tests
+{
+ [TestFixture]
+ public class UnicodeTest
+ {
+ [Test]
+ public void Insert ()
+ {
+ var db = new TestDb ();
+
+ db.CreateTable<Product> ();
+
+ string testString = "\u2329\u221E\u232A";
+
+ db.Insert (new Product {
+ Name = testString,
+ });
+
+ var p = db.Get<Product> (1);
+
+ Assert.AreEqual (testString, p.Name);
+ }
+
+ [Test]
+ public void Query ()
+ {
+ var db = new TestDb ();
+
+ db.CreateTable<Product> ();
+
+ string testString = "\u2329\u221E\u232A";
+
+ db.Insert (new Product {
+ Name = testString,
+ });
+
+ var ps = (from p in db.Table<Product> () where p.Name == testString select p).ToList ();
+
+ Assert.AreEqual (1, ps.Count);
+ Assert.AreEqual (testString, ps [0].Name);
+ }
+ }
+}

0 comments on commit e7f03cb

Please sign in to comment.