Skip to content
Prev 58754 / 63424 Next

`basename` and `dirname` change the encoding to "UTF-8"

Dear R Developers,

I noticed that `basename` and `dirname` always return "UTF-8" on Windows (tested with R-4.0.0 and R-3.6.3):
[1] "latin1"
[1] "UTF-8"
[1] "UTF-8"

Is this on purpose?  At least I did not find any relevant comment in the documentation of `dirname`/`basename`.

Background: I'm currently struggeling with a directory name containing a latin1-character.  (I know that this is a bad idea, but I did not create the directory and I cannot rename it.)  I now want to pass a latin1-directory name to a function, which internally uses `tools::makeLazyLoadDB`.  At that point, internally, `dirname` is called, which changes the encoding, and things break.  If I use `debug` to halt the processing and "fix" the encoding, things work as expected.

So, if possible, I would prefer that `dirname` and `basename` preserve the encoding.

Best regards
Johannes
Message-ID: <trinity-80ed050e-17bd-45ed-983a-5ff860b0daaf-1593441560785@3c-app-webde-bap18>
In-Reply-To: <CANROs4c2nsANgCNH9P3FhMLTk2TOwdZLPW4OLGocHt81vLdS9Q@mail.gmail.com>

Thread (13 messages)

Juan Telleria Ruiz de Aguirre Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 10 Tomas Kalibera Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 10 Dirk Eddelbuettel Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 10 Kevin Ushey Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 10 Juan Telleria Ruiz de Aguirre Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 10 Yihui Xie Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 21 Tomas Kalibera Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 22 Yihui Xie Possible Bug: file.exists() Function. Due to UTF-8 Encoding differences on Windows between R 4.0.1 and R 3.6.3? Jun 23 Johannes Rauh `basename` and `dirname` change the encoding to "UTF-8" Jun 29 Duncan Murdoch `basename` and `dirname` change the encoding to "UTF-8" Jun 29 Kevin Ushey `basename` and `dirname` change the encoding to "UTF-8" Jun 29 Tomas Kalibera `basename` and `dirname` change the encoding to "UTF-8" Jun 30 Johannes Rauh `basename` and `dirname` change the encoding to "UTF-8" Jun 30