detect_encoding: Detect file encoding

View source: R/encoding.R

detect_encodingR Documentation

Detect file encoding

Description

Detect file encoding

Usage

detect_encoding(filepath, n_lines = 10)

Arguments

filepath

Character. Path to file.

n_lines

Integer. Number of initial lines sampled for UTF-8 validity (in addition to a fixed 10 KB raw-byte prefix used for BOM / endianness detection). Sampling the head is sufficient because BOM and byte-order markers appear at file start, and U+FFFD substitution surfaces early.

Value

Character. Detected encoding name.


Rclade documentation built on Sept. 26, 2026, 5:07 p.m.