caleb41610 Posted April 17, 2014 Share Posted April 17, 2014 Local $sFile = @ScriptDir & "index.html" Local $nFileReadSize = FileGetSize($sFile) Local $hFile = FileOpen($sFile) Local $nFileBinarySize = BinaryLen( FileRead($hFile) ) FileClose($hFile) The results are: $nFileReadSize == 630 $nFileBinarySize == 622 I'm using this to send large files in chunks, and I cannot load the whole file in to a string with FileRead() due to memory limitations. I'm also sending it via the web using http. So, I must get the actual BinaryLen() for the http header somehow, without loading the whole file. I'm stumped. My current method has been to load the file in chunks at the initialization stage, calculate each step, and just save the number for any file greater than the memory threshhold. Obviously this will scale badly! Any ideas? Thanks! Multi-Connection TCP Server Link to comment Share on other sites More sharing options...
jchd Posted April 17, 2014 Share Posted April 17, 2014 Use FileOpen in binary mode, else results are more or less meaningless. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
trancexx Posted April 17, 2014 Share Posted April 17, 2014 Files can have BOM which could cause reading wrong size in binary mode. Probably you don't want BOM sent caleb41610? This is just for jchd to see possible issue with his suggestion. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jchd Posted April 17, 2014 Share Posted April 17, 2014 Yes I know well, BOM or lack of can be anything in 0, 2, 3 or 4 bytes. Not 8. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
trancexx Posted April 18, 2014 Share Posted April 18, 2014 Can it be, let's say 5 bytes? ...just that I know what to say when someone asks me that? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
JohnQSmith Posted April 18, 2014 Share Posted April 18, 2014 Can it be, let's say 5 bytes? Yes, for UTF-7. https://en.wikipedia.org/wiki/Byte_order_mark Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Link to comment Share on other sites More sharing options...
trancexx Posted April 18, 2014 Share Posted April 18, 2014 (edited) But would AutoIt know what to do with that BOM? What do you think? How many characters would it read? In size of binary len or fewer? Or third? Edited April 18, 2014 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jchd Posted April 18, 2014 Share Posted April 18, 2014 My suggestion was only for a reliable file length result in binary (that's for the record). UTF7 is a thing of the past, which AutoIt rightfully ignores. Like trancexx knows by heart ( ) UTF8 BOM is 3 bytes, UTF16 BOM (-LE or -BE) is one encoding unit, i.e. 2 bytes. UTF32 BOM (-LE or -BE) is again one encoding unit, i.e. 32-bit or 4 bytes. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now