Skip to content

Commit

Permalink
fix download encoding issue (needs testing)
Browse files Browse the repository at this point in the history
  • Loading branch information
crashdemons committed Apr 14, 2019
1 parent f63b896 commit 45785f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 16 additions & 2 deletions frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,27 @@ function getJsLink(data,mt){
if(typeof mt === "undefined") mt="";
return '#" onclick="' + "dataOverlayStub('"+btoa(data)+"')";
}

function stobuf(str) {
var buf = new ArrayBuffer(str.length*2);
var bufView = new Uint8Array(buf);
for (var i=0, strLen=str.length; i < strLen; i++) {
bufView[i] = str.charCodeAt(i);
if(str.charCodeAt(i)<0 || str.charCodeAt(i)>255){
console.log("!!! "+str.charCodeAt(i));
}
}
return buf;
}
function ieDownloadData(data,filename){
var dlData = getDataBlob(data);
navigator.msSaveBlob(dlData, filename);
}
function getDataBlob(data){
return new Blob([data], {type: 'application/octet-stream;charset=iso-8859-1;'});//TODO: IE is messing up file encoding!
var buf = stobuf(data);
console.log(buf)
//data=decodeURIComponent(escape(data));
//data=unescape(encodeURIComponent(data));
return new Blob([buf], {type: 'application/octet-stream;charset=utf-8;'});//TODO: IE is messing up file encoding!
}

function getDlLink(data, filename){
Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>jpdump - JPEG Header Viewer</title>
<link rel="stylesheet" type="text/css" href="accordion.css">
<link rel="stylesheet" type="text/css" href="style.css?v=2">
<link rel="stylesheet" type="text/css" href="style.css?v=1.1.1">
<script src="compat.js"></script>
<script src="accordion.js"></script>
<script src="xml2json.min.js"></script>
Expand All @@ -17,7 +17,7 @@
<script src="jpeg_decode_exif.js"></script>
<script src="jpeg_decode.js"></script>
<script src="branding.js"></script>
<script src="frontend.js?v=2"></script>
<script src="frontend.js?v=1.1.2"></script>
<script src="/ga.js"></script>
</head>
<body>
Expand Down

0 comments on commit 45785f4

Please sign in to comment.