Putting up a bounty didn't produce a solution to this, so I've spent a while figuring out the best one I could. I don't have any source confirming that this is the correct way to do it, so use at your own risk.
To convert any string into a SQLite identifier:
- Ensure the string can be encoded as UTF-8.
- Ensure the string does not include any NUL characters.
- Replace all
"
with""
. - Wrap the entire thing in double quotes.