Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

to_encoding

Deep conversion to an encoding


Description

Converts all characters directly or indirectly contained in an object to a specific encoding. This works even if the encoding is different in the elements of a character vector.

Usage

to_encoding

to_utf8(x, ...)

to_native(x, ...)

to_latin1(x, ...)

to_alien(x, ...)

## S3 method for class 'character'
to_encoding(x, ..., converter)

Arguments

x

A character vector.

...

passed on to methods

converter

A function that accepts a character value as first argument and returns a (possibly classed) character with the desired encoding

Format

An object of class function of length 1.

Details

to_utf8

converts to UTF-8, using the utf8() class where possible. Implemented as to_encoding(x, as_utf8)

to_native

converts to the native encoding. Implemented as to_encoding(x, enc2native) on Windows and as to_encoding(x, as_utf8) on Linux and OS X

to_latin1

converts to the latin-1 encoding

to_alien

converts to the "other" encoding, i.e., UTF-8 on Windows and latin-1 on Linux and OS X.

See Also

Examples

to_utf8(letters)
to_utf8(iris)
class(levels(to_utf8(iris)$Species))

enc

Portable Tools for 'UTF-8' Character Data

v0.2.2
GPL-3
Authors
Kirill Müller [aut, cre]
Initial release
2019-12-19

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.