Encoding            package:base            R Documentation(latin1)

_R_e_a_d _o_r _S_e_t _t_h_e _D_e_c_l_a_r_e_d _E_n_c_o_d_i_n_g_s _f_o_r _a _C_h_a_r_a_c_t_e_r _V_e_c_t_o_r

_D_e_s_c_r_i_p_t_i_o_n:

     Read or set the declared encodings for a character vector.

_U_s_a_g_e:

     Encoding(x)

     Encoding(x) <- value

_A_r_g_u_m_e_n_t_s:

       x: A character vector.

   value: A character vector of positive length.

_D_e_t_a_i_l_s:

     As from R 2.5.0, character strings in R can be declared to be in
     '"latin1"' or '"UTF-8"'.  These declarations can be read by
     'Encoding', which will return a character vector of values
     '"latin1"', '"UTF-8"' or '"unknown"', or set, when 'value' is
     recycled as needed and other values are silently treated as
     '"unknown"'.

     There are other ways for character strings to acquire a declared
     encoding apart from explicitly setting it.  Functions 'scan',
     'read.table', 'readLines', 'parse' and  'source' have an
     'encoding' argument that is used to declare encodings, 'iconv'
     declares encodings from its 'from' argument, and console input in
     suitable locales is also declared.

_V_a_l_u_e:

     A character vector.

_E_x_a_m_p_l_e_s:

     ## 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)

