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

前端 未结 4 1254
北海茫月
北海茫月 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:33

    If your problem is reinterpretation of escape sequences in sqlite you can (ab)use json_extract eg.

        UPDATE  `tableToFix`  SET  `columnToFix` = json_extract('"'  ||  `columnToFix`  ||  '"', '$');
        INSERT INTO test VALUE (json_extract('"P\u0159\u00edli\u0161 \u017elu\u0165ou\u010dk\u00fd k\u016f\u0148 \u00fap\u011bl \u010f\u00e1belsk\u00e9 \u00f3dy."', '$'));
    

    Notice: quotes handling. Valid json string starts and ends with " so you must add them before use of json_extract

提交回复
热议问题