r-lib / rprojroot

Finding files in project subdirectories
https://rprojroot.r-lib.org/
Other
149 stars 23 forks source link

avoid warnings about invalid inputs with non-native encoding #80

Open bastistician opened 3 years ago

bastistician commented 3 years ago

pkgload::load_all() produces warnings of the type

In grepl(contents, fc, fixed = fixed) :
  input string 5 is invalid in this locale

when used for a latin1-encoded package in a UTF8 locale. These warnings originate from rprojroot::is_r_package() searching for "^Package: " in the DESCRIPTION file. A simple fix is the useBytes = TRUE variant of grepl(). I've added a specific test for the match_contents() utility function.

krlmlr commented 3 years ago

Thanks for tracking this down.

In the interest of backward compatibility I'd prefer if the critiera generators that use match_contents() exposed a use_bytes argument, this can be then used in is_r_package . Would you mind going that extra mile?