Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading binary files

Status
Not open for further replies.

Gramie

Programmer
Aug 8, 2000
2
JP
When I try to read in a binary file, VBScript does some strange things, probably related to Unicode conversion.<br><br>For example, a file that starts off:<br><br>FF D8 FF E0 00 10 4A 46 49 46 00 (a JPEG header)<br><br>looks like this when I print it from VBScript:<br><br>F3 F8 98 FF F3 F8 00 10 4A 46 49 46 00 <br><br>FF has become F3 F8 (I see the same pattern later in the file)<br>D8 has become 98 FF<br>E0 has disappeared completely!<br><br>Is there any way to get VBScript to read in a binary file in a format I can read properly? Or will I have to resort to an external DLL/COM object?<br><br>Any help gratefully appreciated (and yes, I am using MidB, AscB, LeftB, RightB, etc.)<br><br>Graham Stratford
 
Graham,<br>&nbsp;&nbsp;&nbsp;What method are you using to read the file?<br><br> <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
Well, I'm in the middle of solving this right now.<br><br>The problem is not exactly Unicode; it turns out that the changes are being caused by IIS, which doesn't change the binary file to a Unicode string, but to a string of Japanese text! (I'm using a Japanese-language server.)<br><br>I found that I can get a readable stream of bytes if I specifically open the textstream as Unicode -- every character a standard two bytes -- instead of the default ASCII, which (on a Japanese system) means that each character is sometimes one byte, sometimes two.<br><br>Then I have to use the byte-style string-handling functions (LenB, MidB, etc.) to force VBScript to work with bytes.<br><br>Double-byte character sets sure are wild and crazy fun. Don't even get me started on JIS, S-JIS, and EUC encodig!!!<br><br>Thanks for offering to help, though, Nick<br><br>Graham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top