[R] Bug with writeClipboard in {utils}

Barthelemy Tanguy
2024-06-18T10:12:04Z

Hello,

I'm encountering what seems to be a bug when using the `writeClipboard()`
function in the R {utils} package.
When I try to copy text to the clipboard, I notice that I get extra characters
when I try to paste it (by hand with CTRL+V or with the `readClipboard()`
function from R packages {utils}).

Here's my example:

``` r
utils::writeClipboard("plot(AirPassengers)")
for (k in 1:10) {
    print(utils::readClipboard())
}
#> [1] "plot(AirPassengers)" "??"
#> [1] "plot(AirPassengers)" "\u0a00"
#> [1] "plot(AirPassengers)" "\xed\xb0\x80?"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)" "?"
#> [1] "plot(AirPassengers)"
Message d'avis :
Dans utils::readClipboard() : unpaired surrogate Unicode point dc00
```

So I don't always get the same result.
I opened a problem in the {clipr} GitHub repository before realizing it's a
{tools} problem: https://github.com/mdlincoln/clipr/issues/68

Is this a bug or something I haven't configured properly?


Thank you very much


Tanguy BARTHELEMY


	[[alternative HTML version deleted]]