def METHOD_NAME(tmp_path_factory, s: str):
    folder = tmp_path_factory.mktemp('pdfdoc')
    txt: Path = folder / 'pdfdoc.txt'
    with open(txt, 'w', encoding='pdfdoc', newline='') as f:
        try:
            f.write(s)
        except UnicodeEncodeError:
            return
    with open(txt, encoding='pdfdoc', newline='') as f:
        result: str = f.read()
    assert result == s