fixed encoding problime while compression

This commit is contained in:
Maik Hofmann 2021-02-14 17:28:17 +01:00
parent f037286459
commit 75019ba98b
2 changed files with 2 additions and 9 deletions

File diff suppressed because one or more lines are too long

View File

@ -11,7 +11,7 @@ from jsmin import jsmin
content = ""
with open('index.html','rt') as f:
with open('index.html','rt',encoding="utf-8") as f:
content=f.read()
@ -22,13 +22,6 @@ import re
regex = r"<script>(.+?)<\/script>"
content = re.sub(regex, lambda x: "<script>"+jsmin(x.group(1))+"</script>" ,content, 0, re.DOTALL)
#with gzip.open('htmltest.html.gz', 'wb') as f:
# f.write(content.encode("UTF-8"))
#with open('htmltest.html.z','wb') as f:
# f.write(zlib.compress(content.encode("UTF-8"),9))
result =""
for c in zlib.compress(content.encode("UTF-8"),9):
result= result + ("0x%02X" %c)