r-lib/withr

Support UTF-8 content in local_tempfile(lines = )

Closed this issue · 2 comments

We have some code in our test suite that is ripe for replacement by withr::local_tempfile()'s lines= argument, but it needs to support UTF-8 as we test some encoding stuff in that suite:

https://github.com/r-lib/lintr/blob/ccc1e7456f174a91d43744d1ca40252268796db6/tests/testthat/test-get_source_expressions.R#L1-L5

Would the approach there (write to a connection with encoding declared) be more suitable for use in {withr}?

Happy to file a PR.

Yeah, and we should possibly use mode = "wb" to consistently write the same data on windows and linux/mac.

Same as #216 ?