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{ 7native_encode(x) 8} 9\arguments{ 10\item{x}{A character vector.} 11} 12\description{ 13Apply \code{enc2native()} to the character vector, and check if 14\code{enc2utf8()} can convert it back without a loss. If it does, return 15\code{enc2native(x)}, otherwise return the original vector with a warning. 16} 17\note{ 18On platforms that supports UTF-8 as the native encoding 19 (\code{\link{l10n_info}()[['UTF-8']]} returns \code{TRUE}), the conversion 20 will be skipped. 21} 22\examples{ 23library(xfun) 24s = intToUtf8(c(20320, 22909)) 25Encoding(s) 26 27s2 = native_encode(s) 28Encoding(s2) 29} 30