Skip to contents

This function will guess the file encoding of a vector of filenames or filepaths and return the file encoding as a string. It primarily uses stringi::stri_enc_detect() to guess the encoding. Additionally, it searches for known CP850 and CP1252 characters and will return the appropriate encoding if found, because ICU/stringi cannot detect them. If a file is a binary file, it will return "binary". If a file is inaccessible it will return NA for that element.

Usage

guess_file_encoding(filepaths, threshold = 0.2)

Arguments

filepaths

A character vector

threshold

A single element numeric (minimum confidence level of the guess [0-1])

Value

A character vector the same length as filepaths.