brodysoft/Cordova-SQLitePlugin — pull request #84 by nolanlawson (2014-07-09 07:26:15+00:00)
Title: Fix iOS string encoding

This fix ensures that the SQLite Plugin exhibits the same behavior as the native `openDatabase` when dealing with odd Unicode strings like `'\u0000foo\u0000bar'`. Without this fix, it truncates the strings because it assumes that the `\0` is the null terminator.

We make heavy use of this feature in PouchDB, because `'\u0000'`, `'\u0001'`, and `'\u0002'` are needed to ensure universal string ordering across WebSQL, IndexedDB, and LevelDB ([source code](https://github.com/pouchdb/collate/blob/fe504a68b7a90eadee9188298379ceceb7780851/lib/index.js#L81-L89)). And with this fix, I'm happy to report that the PouchDB test suite is now passing on iOS at 100% (same as Android!). So yeah, cheers to that. :)

You may also be interested to know that the SQLite plugin actually deviates from Safari/UIWebView's standard behavior in terms of storing the strings as UTF-8 rather than UTF-16. (PouchDB doesn't care, because we're already accustomed to dealing with UTF-8 in the Chrome/Android implementation.) These unit tests verify that the database is at least using one encoding or the other consistently, so that's just an FYI.