gaborcsardi / rencfaq

The R Encoding FAQ
Creative Commons Zero v1.0 Universal
67 stars 3 forks source link

Add a FAQ bullet about `system()` not marking string output with encoding #7

Open cderv opened 1 year ago

cderv commented 1 year ago

As a windows user, I encountered several times the issue of executing a command with system() and internal = TRUE, then having the surprise of encoding problem. My finding was that string output was not marked with the encoding that the command was using.

Example:

In all case, a solution was to mark the output with the encoding we expect from the command.

It seems there is no single solution to this problem as it depends on how the command will output, but at least knowing about this helps solves some issues.

Opening this issue for discussion, also if others have experience about this.

gaborcsardi commented 1 year ago

FWIW, processx::run() has an encoding argument, which specifies the encoding of stdout and stderr of the command. (Which processx always re-encodes in UTF-8.)

cderv commented 1 year ago

That is definitely a good argument to use processx.

However, it seems the conversion is removing some characters in the conversion. I can open an issue in processx for that.

gaborcsardi commented 1 year ago

Related: https://github.com/r-lib/processx/issues/353