forked from umasolution/htmlEvader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utf_encode.py
61 lines (46 loc) · 1.74 KB
/
utf_encode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import codecs
import commands
class utf_encode():
def __init__(self, filename):
self.filename = filename
print "jayesh %s" % self.filename
def set_utf8bom(self):
with open(self.filename) as df:
dataf = df.read()
print self.filename
out = file(self.filename+"_utf8bom", "w" )
out.write( codecs.BOM_UTF8 )
out.write( dataf.encode( "utf-8" ) )
out.close()
def set_utf7(self):
self.set_utf8bom()
cmd = "iconv -f utf-8 -t utf7 %s_utf8bom > %s_utf7" % (self.filename, self.filename)
status, output = commands.getstatusoutput(cmd)
def set_utf16(self):
self.set_utf8bom()
cmd = "iconv -f utf-8 -t utf16 %s_utf8bom > %s_utf16" % (self.filename, self.filename)
status, output = commands.getstatusoutput(cmd)
def set_utf32(self):
self.set_utf8bom()
cmd = "iconv -f utf-8 -t utf32 %s_utf8bom > %s_utf32" % (self.filename, self.filename)
print "cmd %s" % cmd
status, output = commands.getstatusoutput(cmd)
def set_utf16le(self):
self.set_utf8bom()
cmd = "iconv -f utf-8 -t utf16le %s_utf8bom > %s_utf16le" % (self.filename, self.filename)
status, output = commands.getstatusoutput(cmd)
def set_utf16be(self):
self.set_utf8bom()
cmd = "iconv -f utf-8 -t utf16be %s_utf8bom > %s_utf16be" % (self.filename, self.filename)
status, output = commands.getstatusoutput(cmd)
def set_utf32le(self):
self.set_utf8bom()
cmd = "iconv -f utf-8 -t utf32le %s_utf8bom > %s_utf32le" % (self.filename, self.filename)
status, output = commands.getstatusoutput(cmd)
def set_utf32be(self):
self.set_utf8bom()
cmd = "iconv -f utf-8 -t utf32be %s_utf8bom > %s_utf32be" % (self.filename, self.filename)
status, output = commands.getstatusoutput(cmd)
if __name__ == "__main__":
res = utf_encode('poc.html')
res.set_utf8bom()