[R] Potential Bug: file.show does not support double-byte characters in the file path
t|myu @end|ng |rom protonm@||@com
Thu Jun 17 13:42:48 CEST 2021
I may have come across a bug regarding the file.show function in the base package.
### Bug Description
file.show does not support double-byte characters in the file path.
### Platform Info
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
 LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936
 LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C
 LC_TIME=Chinese (Simplified)_China.936
attached base packages:
 stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
 compiler_4.1.0 tools_4.1.0
### Steps to Reproduce
1. Install R-4.1.0 for Windows on Windows 10 x64 21H1 (Chinese-Simplified, zh-CN)
2. Open RGui
3. Create a file named "test.txt" under "C:\Test", so that the full file path does not include double-byte characters
4. Create a file named "test.txt" under "C:\测试", so that the full file path includes double-byte characters
5. Run the following commands in the console
> t1 = "C:\\Test\\test.txt"
> t2 = "C:\\测试\\test.txt"
In file.show(t2) : file.show(): file 'C:\æµ‹è¯•\test.txt' does not exist
file.show() can correctly open the "C:\Test\test.txt" as the file path does not contain double-byte characters, but it fails to do so for "C:\测试\test.txt".
### Additional information
For users with usernames that include double-byte characters, this bug even prevents demo() from functioning properly.
In file.show(outFile, delete.file = TRUE, title = paste("R", tolower(x$title))) :
file.show() can correctly read from files containing double-byte characters if the file paths do not. For example, the content for "C:\Test\test.txt" can be "Testing 123 测试". file.show("C:\\Test\\test.txt") would open this file and display its content correctly without specifying the encoding parameter.
[[alternative HTML version deleted]]
More information about the R-help