Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
beginsWith -- Check if Byte Array Begins with Byte SequenceDetermine if a byte array begins with a specific byte sequence.
import chilkat zipData = chilkat.CkByteData() gifData = chilkat.CkByteData() # Zip files begin with these 4 bytes: zipBegin = chilkat.CkByteData() zipBegin.append('\x50\x4B\x03\x04',4) # GIF files begin with "GIF89", which is this byte sequence: gifBegin = chilkat.CkByteData() gifBegin.append('\x47\x49\x46\x38\x39',5) success = zipData.loadFile("dude.zip") if (success == True): if (zipData.beginsWith(zipBegin)): print "Yes, this is a .zip archive!" else: print "No, this is not a .zip archive." else: print "Failed to load dude.zip" success = gifData.loadFile("dude.gif") if (success == True): if (gifData.beginsWith(gifBegin)): print "Yes, this is a GIF image!" else: print "No, this is not a GIF image." else: print "Failed to load dude.gif" |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.