Files
wehub-resource-sync c8733f5f8c
ci / test (3.11) (push) Failing after 1s
ci / test (3.12) (push) Failing after 1s
ci / test (3.13) (push) Failing after 0s
ci / test (3.10) (push) Failing after 2s
ci / wheel-gate (push) Failing after 1s
chore: import upstream snapshot with attribution
2026-07-13 12:05:22 +08:00

15 lines
391 B
Python

"""UTF-8-safe text helpers for cross-platform file operations."""
from __future__ import annotations
from pathlib import Path
def read_utf8_text(path: str | Path, default: str = "") -> str:
"""Read text as UTF-8 with replacement semantics."""
target = Path(path)
if not target.exists():
return default
return target.read_text(encoding="utf-8", errors="replace")