53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
path = 'e:/GitHub/blog/public/js/bundle.min.6c8518518bf5af8d666e1b391ef3cf4caaaca7537fd1961891ed292d86eb3fed.js'
|
|
with open(path, 'rb') as f:
|
|
content = f.read()
|
|
|
|
# Find initCodeFold in the binary content
|
|
marker = 'window.initCodeFold=function'.encode('utf-8')
|
|
idx = content.find(marker)
|
|
if idx == -1:
|
|
# Try latin-1 or other encoding
|
|
marker = 'window.initCodeFold=function'.encode()
|
|
idx = content.find(marker)
|
|
|
|
if idx == -1:
|
|
print("initCodeFold definition not found!")
|
|
else:
|
|
# Find the span innerHTML part
|
|
chunk = content[idx:idx+1200]
|
|
# Find '展开代码' or its bytes
|
|
# UTF-8 for 展开代码: e5 b1 95 e5 bc 80 e4 bb a3 e7 a0 81
|
|
# UTF-8 for 收起代码: e6 94 b6 e8 b5 b7 e4 bb a3 e7 a0 81
|
|
target1 = '展开代码'.encode('utf-8')
|
|
target2 = '收起代码'.encode('utf-8')
|
|
|
|
t1_idx = chunk.find(target1)
|
|
t2_idx = chunk.find(target2)
|
|
|
|
print(f"展开代码 found at offset {t1_idx}: {t1_idx != -1}")
|
|
print(f"收起代码 found at offset {t2_idx}: {t2_idx != -1}")
|
|
|
|
# Also check the raw source file
|
|
print()
|
|
print("--- Checking source file ---")
|
|
with open('e:/GitHub/blog/themes/Ying/assets/js/modules/utils.js', 'rb') as f:
|
|
src = f.read()
|
|
t1 = src.find(target1)
|
|
t2 = src.find(target2)
|
|
print(f"展开代码 in source: {t1 != -1}")
|
|
print(f"收起代码 in source: {t2 != -1}")
|
|
|
|
# Check file encoding
|
|
print()
|
|
print(f"Built JS file size: {len(content)} bytes")
|
|
|
|
# Check if file starts with BOM or has other encoding markers
|
|
if content[:3] == b'\xef\xbb\xbf':
|
|
print("File has UTF-8 BOM")
|
|
elif content[:2] == b'\xff\xfe':
|
|
print("File has UTF-16 LE BOM")
|
|
elif content[:2] == b'\xfe\xff':
|
|
print("File has UTF-16 BE BOM")
|
|
else:
|
|
print("No BOM detected - likely UTF-8")
|