Deal with text containing NUL bytes

SQLITE text columns may contain embedded NUL bytes. Here's a test for making sure we can round-trip such text, and a patch to make the test pass.