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

native_encode

Try to use the system native encoding to represent a character vector


Description

Apply enc2native() to the character vector, and check if enc2utf8() can convert it back without a loss. If it does, return enc2native(x), otherwise return the original vector with a warning.

Usage

native_encode(x, windows_only = is_windows())

Arguments

x

A character vector.

windows_only

Whether to make the attempt on Windows only. On Unix, characters are typically encoded in the native encoding (UTF-8), so there is no need to do the conversion.

Examples

library(xfun)
s = intToUtf8(c(20320, 22909))
Encoding(s)

s2 = native_encode(s)
Encoding(s2)

xfun

Miscellaneous Functions to Support Packages Maintained by 'Yihui Xie'

v0.22
MIT + file LICENSE
Authors
Yihui Xie [aut, cre, cph] (<https://orcid.org/0000-0003-0645-5666>), Wush Wu [ctb], Daijiang Li [ctb], Xianying Tan [ctb], Salim Brüggemann [ctb] (<https://orcid.org/0000-0002-5329-5987>), Christophe Dervieux [ctb]
Initial release

We don't support your browser anymore

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