Debian Codegraph @

man/native_encode.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/encoding.R
3 \name{native_encode}
4 \alias{native_encode}
5 \title{Try to use the system native encoding to represent a character vector}
6 \usage{
7 native_encode(x)
8 }
9 \arguments{
10 \item{x}{A character vector.}
11 }
12 \description{
13 Apply \code{enc2native()} to the character vector, and check if \code{enc2utf8()} can
14 convert it back without a loss. If it does, return \code{enc2native(x)}, otherwise
15 return the original vector with a warning.
16 }
17 \note{
18 On platforms that supports UTF-8 as the native encoding
19 (\code{\link[=l10n_info]{l10n_info()}}\verb{[['UTF-8']]} returns \code{TRUE}), the conversion will be
20 skipped.
21 }
22 \examples{
23 library(xfun)
24 s = intToUtf8(c(20320, 22909))
25 Encoding(s)
26
27 s2 = native_encode(s)
28 Encoding(s2)
29 }