The R Project SVN R

Rev

Rev 61433 | Rev 68833 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 61433 Rev 65505
Line 1... Line 1...
1
% File src/library/base/man/Encoding.Rd
1
% File src/library/base/man/Encoding.Rd
2
% Part of the R package, http://www.R-project.org
2
% Part of the R package, http://www.R-project.org
3
% Copyright 1995-2011 R Core Team
3
% Copyright 1995-2014 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{Encoding}
6
\name{Encoding}
7
\alias{Encoding}
7
\alias{Encoding}
8
\alias{Encoding<-}
8
\alias{Encoding<-}
Line 24... Line 24...
24
\arguments{
24
\arguments{
25
  \item{x}{A character vector.}
25
  \item{x}{A character vector.}
26
  \item{value}{A character vector of positive length.}
26
  \item{value}{A character vector of positive length.}
27
}
27
}
28
\details{
28
\details{
29
  Character strings in \R can be declared to be in \code{"latin1"} or
29
  Character strings in \R can be declared to be encoded in
30
  \code{"UTF-8"} or \code{"bytes"}.  These declarations can be read by
30
  \code{"latin1"} or \code{"UTF-8"} or as \code{"bytes"}.  These
31
  \code{Encoding}, which will return a character vector of values
31
  declarations can be read by \code{Encoding}, which will return a
-
 
32
  character vector of values \code{"latin1"}, \code{"UTF-8"}
32
  \code{"latin1"}, \code{"UTF-8"} \code{"bytes"} or \code{"unknown"}, or
33
  \code{"bytes"} or \code{"unknown"}, or set, when \code{value} is
33
  set, when \code{value} is recycled as needed and other values are
34
  recycled as needed and other values are silently treated as
34
  silently treated as \code{"unknown"}.  ASCII strings will never be
35
  \code{"unknown"}.  ASCII strings will never be marked with a declared
35
  marked with a declared encoding, since their representation is the
36
  encoding, since their representation is the same in all supported
36
  same in all supported encodings.  Strings marked as \code{"bytes"} are
37
  encodings.  Strings marked as \code{"bytes"} are intended to be
37
  intended to be non-ASCII strings which should be manipulated as bytes,
38
  non-ASCII strings which should be manipulated as bytes, and never
38
  and never converted to a character encoding.
39
  converted to a character encoding.
39
 
40
 
40
  \code{enc2native} and \code{enc2utf8} convert elements of character
41
  \code{enc2native} and \code{enc2utf8} convert elements of character
41
  vectors to the native encoding or UTF-8 respectively, taking any
42
  vectors to the native encoding or UTF-8 respectively, taking any
42
  marked encoding into account.  They are \link{primitive} functions,
43
  marked encoding into account.  They are \link{primitive} functions,
43
  designed to do minimal copying.
44
  designed to do minimal copying.
Line 46... Line 47...
46
  encoding apart from explicitly setting it (and these have changed as
47
  encoding apart from explicitly setting it (and these have changed as
47
  \R has evolved).  Functions \code{\link{scan}},
48
  \R has evolved).  Functions \code{\link{scan}},
48
  \code{\link{read.table}}, \code{\link{readLines}}, and
49
  \code{\link{read.table}}, \code{\link{readLines}}, and
49
  \code{\link{parse}} have an \code{encoding} argument that is used to
50
  \code{\link{parse}} have an \code{encoding} argument that is used to
50
  declare encodings, \code{\link{iconv}} declares encodings from its
51
  declare encodings, \code{\link{iconv}} declares encodings from its
51
  \code{from} argument, and console input in suitable locales is also
52
  \code{to} argument, and console input in suitable locales is also
52
  declared.  \code{\link{intToUtf8}} declares its output as
53
  declared.  \code{\link{intToUtf8}} declares its output as
53
  \code{"UTF-8"}, and output text connections (see
54
  \code{"UTF-8"}, and output text connections (see
54
  \code{\link{textConnection}}) are marked if running in a
55
  \code{\link{textConnection}}) are marked if running in a
55
  suitable locale.  Under some circumstances (see its help page)
56
  suitable locale.  Under some circumstances (see its help page)
56
  \code{\link{source}(encoding=)} will mark encodings of character
57
  \code{\link{source}(encoding=)} will mark encodings of character
Line 81... Line 82...
81
  \code{\link{duplicated}} and \code{\link{unique}} all match in UTF-8
82
  \code{\link{duplicated}} and \code{\link{unique}} all match in UTF-8
82
  if any of the elements are marked as UTF-8.
83
  if any of the elements are marked as UTF-8.
83
}
84
}
84
\value{
85
\value{
85
  A character vector.
86
  A character vector.
-
 
87
 
-
 
88
  For \code{enc2utf8} encodings are always marked: they are for
-
 
89
  \code{enc2native} in UTF-8 and Latin-1 locales.
86
}
90
}
87
\examples{
91
\examples{
88
## x is intended to be in latin1
92
## x is intended to be in latin1
89
x <- "fa\xE7ile"
93
x <- "fa\xE7ile"
90
Encoding(x)
94
Encoding(x)