readr (version 1.0.0)

guess_encoding: Guess encoding of file.

Description

Uses stri_enc_detect: see the documentation there for caveats.

Usage

guess_encoding(file, n_max = 10000, threshold = 0.2)

Arguments

file
Either a path to a file, a connection, or literal data (either a single string or a raw vector).

Files ending in .gz, .bz2, .xz, or .zip will be automatically uncompressed. Files starting with http://, https://, ftp://, or ftps:// will be automatically downloaded. Remote gz files can also be automatically downloaded & decompressed.

Literal data is most useful for examples and tests. It must contain at least one new line to be recognised as data (instead of a path).

n_max
Number of lines to read. If n_max is -1, all lines in file will be read.
threshold
Only report guesses above this threshold of certainty.

Examples

Run this code
guess_encoding(readr_example("mtcars.csv"))
guess_encoding("a\n\u00b5\u00b5")

Run the code above in your browser using DataCamp Workspace