code: function stringToArrayBuffer(str) {
      var buf=new Uint8Array(str.length);
      for (var i=0; i<str.length; i++) {
        var ch = str.charCodeAt(i);
        if (ch>=256) {
          console.warn("stringToArrayBuffer got non-8 bit character - code "+ch);
          ch = "?".charCodeAt(0);
        }
        buf[i] = ch;
      }
      return buf.buffer;
    }
docs: Converts a string to an ArrayBuffer