-
Notifications
You must be signed in to change notification settings - Fork 160
UTF-8 strings get encoded incorrectly #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'd think that this is expected behavior, since in case 2, you're explicitly passing a string (which is UTF16), and in other cases, you're letting the library take care of the encoding. Unfortunately, strings are always represented as UTF16 internally. So there's no way to work around it, unless you're playing with bytes. |
I think praeclarum did solve this already with this declaration of Prepare2. [DllImport ("sqlite3", EntryPoint = "sqlite3_prepare_v2", CallingConvention = CallingConvention.Cdecl)]
public static extern Result Prepare2 (IntPtr db, byte[] queryBytes, int numBytes, out IntPtr stmt, IntPtr pzTail); And then encode the strings. public static IntPtr Prepare2 (IntPtr db, string query)
{
IntPtr stmt;
byte[] queryBytes = System.Text.UTF8Encoding.UTF8.GetBytes (query);
var r = Prepare2 (db, queryBytes, queryBytes.Length, out stmt, IntPtr.Zero);
[...]
} This seems to work just fine. |
In Prepare2, why is there this differentiation between NETFX_CORE and non-NETFX_CORE? I think the NETFX_CORE version should always be used as strings are always UTF-16 encoded.
|
I'm building a universal store project for Windows 8.1 and Windows Phone 8.1.
I insert data into tables both through ORM objects and through direct requests.
This works fine through ORM or via requests with @params in query, but writing a direct request breaks text encoding.
Is this an expected behaviour? Do I need to encode text somehow?
The text was updated successfully, but these errors were encountered: