file.encoding: File Encoding

Description Usage Arguments Value Note See Also Examples

View source: R/file.encoding.R

Description

Examine file encoding.

Usage

1

Arguments

file

a filename.

Value

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

This function requires the file shell command. If the file utility is not found in the path, this function looks for it inside c:/Rtools/bin. If the required software is not installed, 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

1
2
3
4
5
6
7
## 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 April 7, 2021, 5:06 p.m.