Pull base64.js from noVNC.

Better illegal character debug output.
This commit is contained in:
Joel Martin 2012-02-20 15:49:18 -06:00
parent 31716a7265
commit cb839e85c4
1 changed files with 3 additions and 2 deletions

View File

@ -41,7 +41,6 @@
*
* ***** END LICENSE BLOCK ***** */
"use strict";
/*jslint white: false, bitwise: false, plusplus: false */
/*global console */
@ -52,6 +51,7 @@ toBase64Table : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+
base64Pad : '=',
encode: function (data) {
"use strict";
var result = '',
chrTable = Base64.toBase64Table.split(''),
pad = Base64.base64Pad,
@ -95,6 +95,7 @@ toBinaryTable : [
],
decode: function (data, offset) {
"use strict";
offset = typeof(offset) !== 'undefined' ? offset : 0;
var binTable = Base64.toBinaryTable,
pad = Base64.base64Pad,
@ -115,7 +116,7 @@ decode: function (data, offset) {
padding = (data.charAt(i) === pad);
// Skip illegal characters and whitespace
if (c === -1) {
console.error("Illegal character '" + data.charCodeAt(i) + "'");
console.error("Illegal character code " + data.charCodeAt(i) + " at position " + i);
continue;
}