read_lines_any_encoding: Read a text file, trying several encodings in turn.

View source: R/io.R

read_lines_any_encodingR Documentation

Read a text file, trying several encodings in turn.

Description

EndNote / Web of Science / Zotero RIS and CSV exports on Windows are frequently Windows-1252 or Latin-1, not UTF-8. Hardcoding encoding = "UTF-8" caused readLines to mark strings as UTF-8 even when bytes were invalid, and downstream grepl/regexpr threw "input string N is invalid in this locale". Try encodings in descending likelihood and return the first that decodes cleanly.

Usage

read_lines_any_encoding(path)

Arguments

path

File path.

Value

Character vector of lines.


screenllm documentation built on Sept. 24, 2026, 5:11 p.m.