Skip to content

Passing UTF-16 strings to sqlite3 functions that expect UTF-8 #1

@gburt

Description

@gburt

I haven't actually verified this bug with a test case, but from reading the code it seems you call sqlite3_open, sqlite3_prepare_v2, sqlite3_bind_parameter_index, and sqlite3_bind_text with .NET strings (which are UTF-16) but those methods expect (null-terminated) UTF-8. You can get the UTF-8 bytes to pass with:

System.Text.Encoding.UTF8.GetBytes (str + '\0');

I got bit by this recently when making my own sqlite binding for use in Banshee: http://git.gnome.org/browse/hyena/tree/Hyena.Data.Sqlite/Hyena.Data.Sqlite/Sqlite.cs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions