diff --git a/tests/tools/test_read_enhancements.py b/tests/tools/test_read_enhancements.py index 7e5b9264e..b5fddefdb 100644 --- a/tests/tools/test_read_enhancements.py +++ b/tests/tools/test_read_enhancements.py @@ -121,6 +121,23 @@ class TestReadDedup: assert "1| name" in result assert "2| café" in result + @pytest.mark.parametrize("encoding", ["utf-8-sig", "utf-16", "utf-32"]) + @pytest.mark.asyncio + async def test_bom_marked_unicode_text_uses_declared_encoding( + self, + tool, + tmp_path, + encoding, + ): + f = tmp_path / "unicode.txt" + f.write_bytes("Hello 世界\nSecond line".encode(encoding)) + + result = await tool.execute(path=str(f)) + + assert "1| Hello 世界" in result + assert "2| Second line" in result + assert "\x00" not in result + # --------------------------------------------------------------------------- # Cross-session isolation (issue #3571)