OZONE Asylum
Forums
DHTML/Javascript
Reading special characters with FileSystemObject
This page's ID:
27909
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Yuppers, it sure does [b]Poi[/b]. Here's the function I use for testing. It's supported by a few conversion functions for dates, times, sizes etc, and also an algorithm to Bdecode the file contents. [code] function decodeData(){ // Read resume.dat with Unicode try{ var str = new ActiveXObject("ADODB.Stream"); str.Type = 2; //adTypeText str.Open(); str.loadFromFile("....\\uTorrent\\resume.dat"); str.Charset="Unicode" var unicodeString=str.readText(); str.close(); str = null; } catch(er){return "ERROR"} // Split the Unicode characters, 8 bits rule! var UInt8Array = [],charCode; while( unicodeString.length ) { charCode = unicodeString.charCodeAt(0); UInt8Array.push( charCode&255, charCode>>8 ); unicodeString = unicodeString.substr( 1 ); } for(i in UInt8Array){ UInt8Array[i]=String.fromCharCode(UInt8Array[i]); } var txt=UInt8Array.join(""); UInt8Array=null; // Unserialize the object =) var decoder=new BDecoder(); decoder.data=txt; var result=decoder.decodeEntry(); // Find out what we got... var out=""; for(i in result){ out+=i+":\n" for(j in result[i]){ switch(j){ case "have": case"prio": case "peers": continue; case "info": out+="\t"+j+": "+convertHash(result[i][j])+"\n"; break; case "downloaded": case "uploaded": case "blocksize": out+="\t"+j+": "+convertSize(result[i][j])+"\n"; break; case "downspeed": case "upspeed": out+="\t"+j+": "+convertSize(result[i][j])+"/s\n"; break; case "added_on": case "time": out+="\t"+j+": "+convertDate(result[i][j])+"\n" break; case "runtime": case "seedtime": out+="\t"+j+": "+convertTime(result[i][j])+"\n" break; default: out+="\t"+j+": "+result[i][j]+"\n"; } } } return out; } function convertHash(string){ var hex=""; for(var k=0;k<string.length;k++){ hex+=string.charCodeAt(k).toString(16).toUpperCase(); } return hex; } [/code] /TwoD
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »