File: native_encode.Rd

package info (click to toggle)
r-cran-xfun 0.20-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 680 kB
  • sloc: ansic: 242; sh: 22; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 827 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/encoding.R
\name{native_encode}
\alias{native_encode}
\title{Try to use the system native encoding to represent a character vector}
\usage{
native_encode(x, windows_only = is_windows())
}
\arguments{
\item{x}{A character vector.}

\item{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.}
}
\description{
Apply \code{enc2native()} to the character vector, and check if
\code{enc2utf8()} can convert it back without a loss. If it does, return
\code{enc2native(x)}, otherwise return the original vector with a warning.
}
\examples{
library(xfun)
s = intToUtf8(c(20320, 22909))
Encoding(s)

s2 = native_encode(s)
Encoding(s2)
}