\inputencoding{latin1}
\HeaderA{Encoding}{Read or Set the Declared Encodings for a Character Vector}{Encoding}
\aliasA{Encoding<\Rdash}{Encoding}{Encoding<.Rdash.}
\keyword{utilities}{Encoding}
\keyword{character}{Encoding}
\begin{Description}\relax
Read or set the declared encodings for a character vector.
\end{Description}
\begin{Usage}
\begin{verbatim}
Encoding(x)

Encoding(x) <- value
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] A character vector.
\item[\code{value}] A character vector of positive length.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Character strings in \R{} can be declared to be in
\code{"latin1"} or \code{"UTF-8"}.  These declarations can be read by
\code{Encoding}, which will return a character vector of values
\code{"latin1"}, \code{"UTF-8"} or \code{"unknown"}, or set, when
\code{value} is recycled as needed and other values are silently
treated as \code{"unknown"}.

There are other ways for character strings to acquire a declared
encoding apart from explicitly setting it.  Functions
\code{\LinkA{scan}{scan}}, \code{\LinkA{read.table}{read.table}}, \code{\LinkA{readLines}{readLines}},
\code{\LinkA{parse}{parse}} and  \code{\LinkA{source}{source}} have an \code{encoding}
argument that is used to declare encodings, \code{\LinkA{iconv}{iconv}}
declares encodings from its \code{from} argument, and console input in
suitable locales is also declared.
\end{Details}
\begin{Value}
A character vector.
\end{Value}
\begin{Examples}
\begin{ExampleCode}
## x is intended to be in latin1
x <- "fa\xE7ile"
Encoding(x)
Encoding(x) <- "latin1"
x
xx <- iconv(x, "latin1", "UTF-8")
Encoding(c(x, xx))
c(x, xx)
\end{ExampleCode}
\end{Examples}

