Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #37 from RReverser/master

Untar demo works in IE7 again
  • Loading branch information...
commit 062b5dd49b7c46a87a4349adeafdc5082cc77fb7 2 parents 4ec8e24 + dc52b25
@vjeux vjeux authored
Showing with 14 additions and 8 deletions.
  1. +4 −2 demo/untar/untar.html
  2. +10 −6 src/jdataview.js
View
6 demo/untar/untar.html
@@ -1,8 +1,10 @@
-<script src="../../jquery/jquery-1.4.4-binary-ajax.js"></script>
+<script src="json.js"></script>
+<script src="../../jquery/jquery-1.7.1-binary-ajax.js"></script>
<script src="../../src/jdataview.js"></script>
<style>
textarea { width: 80%; height: 300px; }
+pre { word-wrap: break-word; }
</style>
<p>Content of the file <a href="jquery.tar">jquery.tar</a></p>
@@ -60,6 +62,6 @@
}
// Download the file
-$.get('jquery.tar', tar, 'binary');
+$.get('jquery.tar', tar);
</script>
View
16 src/jdataview.js
@@ -326,13 +326,19 @@ var jDataView = function (buffer, byteOffset, byteLength, littleEndian) {
}
};
+function getCharCodes(string) {
+ var codes = new Array(string.length);
+ for (var i = 0, length = string.length; i < length; i++) {
+ codes[i] = string.charCodeAt(i) & 0xff;
+ }
+ return codes;
+}
+
// mostly internal function for wrapping any supported input (String or Array-like) to best suitable buffer format
jDataView.wrapBuffer = function (buffer) {
switch (typeof buffer) {
case 'string':
- buffer = Array.prototype.map.call(buffer, function (char) {
- return char.charCodeAt(0) & 0xff;
- });
+ buffer = getCharCodes(buffer);
break;
case 'number':
@@ -481,9 +487,7 @@ jDataView.prototype = {
},
setString: function (byteOffset, subString) {
- this.setBytes(byteOffset, Array.prototype.map.call(subString, function (char) {
- return char.charCodeAt(0) & 0xff;
- }), true);
+ this.setBytes(byteOffset, getCharCodes(subString), true);
},
writeString: function (subString) {
Please sign in to comment.
Something went wrong with that request. Please try again.