Skip to content

Database Format for the open() Method

Christopher Weiss edited this page Dec 8, 2013 · 3 revisions

To open an existing database you must supply the SQL.open() method with an array of integers where each integer represents a byte of the database file. The following is a utility function to perform this task:

function bin2Array(bin) {
    'use strict';
    var i, size = bin.length, ary = [];
    for (i = 0; i < size; i++) {
        ary.push(bin.charCodeAt(i) & 0xFF);
    }
    return ary;
}

When fetching a database file via XMLHttpRequest you must use overrideMimeType() before send() to set the mime type to 'text/plain; charset=x-user-defined'.