Determine whether a file is “plain-text” or some sort of binary format
Determine whether a file is “plain-text” or some sort of binary format
is_file_text(file, maxsize = Inf, text_bytes = as.raw(c(7:16, 18, 19, 32:255)))
file |
Path to the file |
maxsize |
Maximum number of bytes to read |
text_bytes |
Which characters are used by normal text (though not
necessarily just ASCII). To detect just ASCII, the
following value can be used:
|
A logical
library(datasets) export(iris, "iris.yml") is_file_text("iris.yml") # TRUE export(iris, "iris.sav") is_file_text("iris.sav") # FALSE # cleanup unlink("iris.yml") unlink("iris.sav")
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.