guess_file_encoding: Guess the file encoding for a vector of filenames or...

View source: R/guess_file_encoding.R

guess_file_encodingR Documentation

Guess the file encoding for a vector of filenames or filepaths

Description

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.


2DegreesInvesting/PACTA_analysis documentation built on April 19, 2023, 6:42 p.m.