title: SQLite Windows Phone character encoding not working
body: <p>I'm working on a Windows Phone 8.1 app with an SQLite database to store localized strings. I use the SQLite for Windows Phone 8.1 extension for this, and I'm programming in C#. However, when I store the localized strings in the database, special characters like 'å', 'ö' etc. appear as '�' in the SQLite database.</p>
  
  <p>I already tried the following:</p>
  
  <p>1) convert the C# strings to UTF-8, UTF-16 or Unicode before storing them in the database, with no help. It appears that encoding strings in C# is useless.</p>
  
  <p>2) set the SQLite database to use UTF-16 encoding with PRAGMA encoding="UTF-16"; when creating the database. The pragma is correctly processed, but the special characters are still '�'.</p>
  
  <p>My assumption is that there is something going wrong in the C++ code of the SQLite for Windows Phone 8.1 extension.</p>
  
  <p>Storing the localized strings elsewhere is not an option, so how can I get the SQLite for Windows Phone 8.1 extension to store the special characters correctly?</p>
  
  <p>C# code:</p>
  
  <pre><code>public IEnumerable&lt;IDictionary&lt;string,object&gt;&gt; ExecuteQuery(string query)
  {
      lock (LockObject)
      {
          var sqCommand = new SQLiteCommand(_sqLiteConnection) { CommandText = query };
          return sqCommand.ExecuteQueryEx();
      }
  }
  </code></pre>
  
  <p>and the query executed is:</p>
  
  <pre><code>INSERT INTO LocalizedStrings (Id, LocalizedKey_Id, Language_Id, StringValue) VALUES (13,13,1053,'Sökområde');
  </code></pre>
  
  <p>And the SQLiteCommand.ExecuteQueryEx code:</p>
  
  <pre><code>public IEnumerable&lt;IDictionary&lt;string,object&gt;&gt; ExecuteQueryEx()
  {
      if (_conn.Trace)
      {
          Debug.WriteLine("Executing Query: " + this);
      }
      var result = new List&lt;Dictionary&lt;string,object&gt;&gt;();
      var stmt = Prepare();
  
      while (SQLite3.Step(stmt) == SQLite3.Result.Row)
      {
          var columnCount = SQLite3.ColumnCount(stmt);
          var row = new Dictionary&lt;string,object&gt;();
  
          for (var i = 0; i &lt; columnCount; i++)
          {
              var columnName = Marshal.PtrToStringAnsi(SQLite3.ColumnName(stmt, i));
              var columnType = SQLite3.ColumnType(stmt, i);
              var value = ReadColEx(stmt, i, columnType);
              row.Add(columnName, value);
          }
          result.Add(row);
      }
  
      Finalize(stmt);
  
      return result;
  }
  </code></pre>