How do I quote a UTF-8 String Literal in Sqlite3

前端 未结 4 1258
北海茫月
北海茫月 2020-12-20 20:37

I\'m looking to encode and store Unicode in a Sqlite database. Is there any way to raw encode a UTF-8 (unicode) string literal in a sql query.

I\'m looking for some

4条回答
  •  盖世英雄少女心
    2020-12-20 21:32

    If you configure your database to use UTF-8 (I believe this is default for many installations; do PRAGMA encoding="UTF-8"; at schema creation time to be certain), this shouldn't be an issue.

    If you send SQLite3 a set of characters encoded in UTF-8, it should have no problem dealing with it.

    If Java has the ability to allow you to "toss a \u0039 into a string", I'd just use that, and ensure that when you try to place the string into the database, that you have the string convert to a UTF-8 byte encoding using whatever mechanism Java provides. I do not believe SQLite provides or needs to provide this for you.

提交回复
热议问题