file.encoding: File Encoding

View source: R/file.encoding.R

file.encodingR Documentation

File Encoding

Description

Examine file encoding.

Usage

file.encoding(file)

Arguments

file

a filename.

Value

"latin1", "UTF-8", "unknown", or NA.

This function requires the file shell command to be in the path. Otherwise, this function returns NA.

Note

The encoding "unknown" indicates that the file is an ASCII text file or a binary file.

In TAF, text files that have non-ASCII characters should be encoded as UTF-8.

If this function fails in Windows, the guess_encoding function in the readr package may help.

See Also

Encoding examines the encoding of a string.

latin1.to.utf8 converts files from ⁠latin1⁠ to ⁠UTF-8⁠ encoding.

line.endings examines line endings.

TAF-package gives an overview of the package.

Examples

## Not run: 
file.base <- system.file(package="base", "DESCRIPTION")
file.nlme <- system.file(package="nlme", "DESCRIPTION")
file.encoding(file.base)  # ASCII
file.encoding(file.nlme)

## End(Not run)


TAF documentation built on March 31, 2023, 6:51 p.m.