Files
Yuzu-GCA/read_png.py
2026-07-19 22:57:19 +08:00

36 lines
1.1 KiB
Python

"""
Read screen.png as UTF-16 LE text and save decoded text to file.
"""
import sys
path = r"D:\Yuzu-GCA\screen.png"
out_path = r"D:\Yuzu-GCA\screen_decoded.txt"
# Read raw bytes
with open(path, 'rb') as f:
raw = f.read()
print(f"File size: {len(raw)} bytes")
# Decode as UTF-16 LE (skip BOM)
text = raw.decode('utf-16-le')
print(f"Decoded text length: {len(text)} characters")
# Write full decoded text to file
with open(out_path, 'w', encoding='utf-8') as f:
f.write(text)
print(f"Full decoded text written to: {out_path}")
# Print first 3000 chars (replace non-printable)
safe_text = text[:3000].encode('ascii', errors='replace').decode('ascii')
print("\n=== First 3000 characters (non-ASCII replaced) ===")
print(safe_text)
# Search for specific keywords
keywords = ['manifest', 'download', 'SHA256', 'verify', 'install', 'OTA', 'version', 'error', 'fail', 'success', 'pass', 'update', '下载', '校验', '安装', '版本']
print("\n=== Keyword search ===")
for kw in keywords:
count = text.count(kw)
if count > 0:
print(f"'{kw}' found {count} times")