I’m using sqlite3_exec() function in order to execute an SQL Insert command. The problem starts when I need to insert strings that need to be encoded.
For example, I want to insert the following string: “f(‘hello’)”. If I want to insert this string I need to change “‘” to “””.
My question is, how do I encode these strings? Is there a function I can count on? or a table that details all the needed encodes?
Thanks! 🙂
Instead of manually escaping strings (which is error-prone and invites SQL injection attacks), I’d strongly recommend using prepared statements and bind values; read up on sqlite3_bind_XXX and sqlite3_prepare_v2