Tim
2021-Jun-17 11:42 UTC
[R] Potential Bug: file.show does not support double-byte characters in the file path
Hi, 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> sessionInfo()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 locale: [1] LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936 [3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C [5] LC_TIME=Chinese (Simplified)_China.936 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] 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" > t1[1] "C:\\Test\\test.txt"> file.show(t1) > > t2 = "C:\\??\\test.txt" > t2[1] "C:\\??\\test.txt"> file.show(t2)Warning message: In file.show(t2) : file.show(): file 'C:\??????\test.txt' does not exist Actual Result: 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.> demo()Warning message: In file.show(outFile, delete.file = TRUE, title = paste("R", tolower(x$title))) : file.show():???'C:\Users\?????1\AppData\Local\Temp\RtmpGuWTun\RpackageIQR197068c75431'???? 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. Thanks, Tim [[alternative HTML version deleted]]