native_encode {xfun} | R Documentation |
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)
Arguments
x |
A character vector. |
Note
On platforms that supports UTF-8 as the native encoding
(l10n_info()
[['UTF-8']]
returns TRUE
), the conversion will be
skipped.
Examples
library(xfun)
s = intToUtf8(c(20320, 22909))
Encoding(s)
s2 = native_encode(s)
Encoding(s2)
[Package xfun version 0.46 Index]