diff --git a/skills/minimax-xlsx/scripts/formula_check.py b/skills/minimax-xlsx/scripts/formula_check.py index ee3ce157..e2cf1131 100644 --- a/skills/minimax-xlsx/scripts/formula_check.py +++ b/skills/minimax-xlsx/scripts/formula_check.py @@ -33,6 +33,14 @@ import re import json +# Windows pipes default to a legacy codepage (e.g. cp1252) that cannot encode +# the ✓/→ characters these tools print - degrade to "?" instead of crashing. +for _stream in (sys.stdout, sys.stderr): + try: + _stream.reconfigure(errors="replace") + except (AttributeError, ValueError): + pass + # OOXML SpreadsheetML namespace NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main" NSP = f"{{{NS}}}" diff --git a/skills/minimax-xlsx/scripts/libreoffice_recalc.py b/skills/minimax-xlsx/scripts/libreoffice_recalc.py index 5699e89f..9279b538 100644 --- a/skills/minimax-xlsx/scripts/libreoffice_recalc.py +++ b/skills/minimax-xlsx/scripts/libreoffice_recalc.py @@ -28,6 +28,14 @@ import tempfile import argparse +# Windows pipes default to a legacy codepage (e.g. cp1252) that cannot encode +# the ✓/→ characters these tools print - degrade to "?" instead of crashing. +for _stream in (sys.stdout, sys.stderr): + try: + _stream.reconfigure(errors="replace") + except (AttributeError, ValueError): + pass + # ── LibreOffice discovery ─────────────────────────────────────────────────── diff --git a/skills/minimax-xlsx/scripts/shared_strings_builder.py b/skills/minimax-xlsx/scripts/shared_strings_builder.py index 9ef35991..a2f59973 100644 --- a/skills/minimax-xlsx/scripts/shared_strings_builder.py +++ b/skills/minimax-xlsx/scripts/shared_strings_builder.py @@ -31,6 +31,14 @@ import html import argparse +# Windows pipes default to a legacy codepage (e.g. cp1252) that cannot encode +# the ✓/→ characters these tools print - degrade to "?" instead of crashing. +for _stream in (sys.stdout, sys.stderr): + try: + _stream.reconfigure(errors="replace") + except (AttributeError, ValueError): + pass + HEADER = '' SST_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main" diff --git a/skills/minimax-xlsx/scripts/style_audit.py b/skills/minimax-xlsx/scripts/style_audit.py index 96205f82..57ea57ea 100644 --- a/skills/minimax-xlsx/scripts/style_audit.py +++ b/skills/minimax-xlsx/scripts/style_audit.py @@ -31,6 +31,14 @@ import tempfile import shutil +# Windows pipes default to a legacy codepage (e.g. cp1252) that cannot encode +# the ✓/→ characters these tools print - degrade to "?" instead of crashing. +for _stream in (sys.stdout, sys.stderr): + try: + _stream.reconfigure(errors="replace") + except (AttributeError, ValueError): + pass + NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main" NSP = f"{{{NS}}}" diff --git a/skills/minimax-xlsx/scripts/xlsx_add_column.py b/skills/minimax-xlsx/scripts/xlsx_add_column.py index 3374e3bb..3e61250f 100644 --- a/skills/minimax-xlsx/scripts/xlsx_add_column.py +++ b/skills/minimax-xlsx/scripts/xlsx_add_column.py @@ -32,6 +32,14 @@ import xml.dom.minidom import xml.etree.ElementTree as ET +# Windows pipes default to a legacy codepage (e.g. cp1252) that cannot encode +# the ✓/→ characters these tools print - degrade to "?" instead of crashing. +for _stream in (sys.stdout, sys.stderr): + try: + _stream.reconfigure(errors="replace") + except (AttributeError, ValueError): + pass + NS_SS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main" NS_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships" diff --git a/skills/minimax-xlsx/scripts/xlsx_insert_row.py b/skills/minimax-xlsx/scripts/xlsx_insert_row.py index 9dc5d6ec..59944da0 100644 --- a/skills/minimax-xlsx/scripts/xlsx_insert_row.py +++ b/skills/minimax-xlsx/scripts/xlsx_insert_row.py @@ -34,6 +34,14 @@ import xml.dom.minidom import xml.etree.ElementTree as ET +# Windows pipes default to a legacy codepage (e.g. cp1252) that cannot encode +# the ✓/→ characters these tools print - degrade to "?" instead of crashing. +for _stream in (sys.stdout, sys.stderr): + try: + _stream.reconfigure(errors="replace") + except (AttributeError, ValueError): + pass + NS_SS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main" NS_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships" diff --git a/skills/minimax-xlsx/scripts/xlsx_pack.py b/skills/minimax-xlsx/scripts/xlsx_pack.py index 41bc208e..bad455e3 100644 --- a/skills/minimax-xlsx/scripts/xlsx_pack.py +++ b/skills/minimax-xlsx/scripts/xlsx_pack.py @@ -18,6 +18,14 @@ import zipfile import xml.etree.ElementTree as ET +# Windows pipes default to a legacy codepage (e.g. cp1252) that cannot encode +# the ✓/→ characters these tools print - degrade to "?" instead of crashing. +for _stream in (sys.stdout, sys.stderr): + try: + _stream.reconfigure(errors="replace") + except (AttributeError, ValueError): + pass + def validate_xml_files(source_dir: str) -> list[str]: """Return list of XML files that fail to parse.""" diff --git a/skills/minimax-xlsx/scripts/xlsx_reader.py b/skills/minimax-xlsx/scripts/xlsx_reader.py index 00e34320..7f735ce0 100644 --- a/skills/minimax-xlsx/scripts/xlsx_reader.py +++ b/skills/minimax-xlsx/scripts/xlsx_reader.py @@ -22,6 +22,14 @@ import argparse from pathlib import Path +# Windows pipes default to a legacy codepage (e.g. cp1252) that cannot encode +# the ✓/→ characters these tools print - degrade to "?" instead of crashing. +for _stream in (sys.stdout, sys.stderr): + try: + _stream.reconfigure(errors="replace") + except (AttributeError, ValueError): + pass + # --------------------------------------------------------------------------- # Format detection and loading diff --git a/skills/minimax-xlsx/scripts/xlsx_shift_rows.py b/skills/minimax-xlsx/scripts/xlsx_shift_rows.py index 5fef29d2..d2280e4d 100644 --- a/skills/minimax-xlsx/scripts/xlsx_shift_rows.py +++ b/skills/minimax-xlsx/scripts/xlsx_shift_rows.py @@ -39,6 +39,14 @@ import xml.etree.ElementTree as ET import xml.dom.minidom +# Windows pipes default to a legacy codepage (e.g. cp1252) that cannot encode +# the ✓/→ characters these tools print - degrade to "?" instead of crashing. +for _stream in (sys.stdout, sys.stderr): + try: + _stream.reconfigure(errors="replace") + except (AttributeError, ValueError): + pass + def col_letter(n: int) -> str: """Convert 1-based column number to Excel column letter(s).""" diff --git a/skills/minimax-xlsx/scripts/xlsx_unpack.py b/skills/minimax-xlsx/scripts/xlsx_unpack.py index 99580ac1..f22a473c 100644 --- a/skills/minimax-xlsx/scripts/xlsx_unpack.py +++ b/skills/minimax-xlsx/scripts/xlsx_unpack.py @@ -18,6 +18,14 @@ import shutil import xml.dom.minidom +# Windows pipes default to a legacy codepage (e.g. cp1252) that cannot encode +# the ✓/→ characters these tools print - degrade to "?" instead of crashing. +for _stream in (sys.stdout, sys.stderr): + try: + _stream.reconfigure(errors="replace") + except (AttributeError, ValueError): + pass + def pretty_print_xml(content: bytes) -> str: """Pretty-print XML bytes. Returns original content on parse failure."""