\HeaderA{localeToCharset}{Select a Suitable Encoding Name from a Locale Name}{localeToCharset}
\keyword{utilities}{localeToCharset}
\begin{Description}\relax
This functions aims to find a suitable coding for the locale named, by
default the current locale, and if it is a UTF-8 locale a suitable
single-byte encoding.
\end{Description}
\begin{Usage}
\begin{verbatim}
localeToCharset(locale = Sys.getlocale("LC_CTYPE"))
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{locale}] character string naming a locale.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The operation differs by OS.
Locale names are normaly like \code{es\_MX.iso88591}.  If final
component indicates an encoding and it is not \code{utf8} we just need
to look up the equivalent encoding name.  Otherwise, the language
(here \code{es}) is used to choose a primary or fallback encoding.

In the \code{C} locale the answer will be \code{"ASCII"}.
\end{Details}
\begin{Value}
A character vector naming an encoding and possibly a fallback
single-encoding,  \code{NA} if unknown.
\end{Value}
\begin{Note}\relax
The encoding names are those used by \code{libiconv}, and ought also
to work with \code{glibc} but maybe not with commercial Unixen.
\end{Note}
\begin{SeeAlso}\relax
\code{\LinkA{Sys.getlocale}{Sys.getlocale}}, \code{\LinkA{iconv}{iconv}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
localeToCharset()
\end{ExampleCode}
\end{Examples}

