Created
December 8, 2011 22:11
-
-
Save kayru/1448896 to your computer and use it in GitHub Desktop.
Create array from binary file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import textwrap | |
s=open(sys.argv[1], 'rb').read().encode("hex").upper() | |
t=",".join(["0x"+x+y for (x,y) in zip(s[0::2], s[1::2])]) | |
print "const unsigned char data[] = {\n\t%s\n};"%" \n\t".join(textwrap.wrap(t,80)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment