AsciiToInt              package:sfsmisc              R Documentation

_C_h_a_r_a_c_t_e_r _t_o _a_n_d _f_r_o_m _I_n_t_e_g_e_r _C_o_d_e_s _C_o_n_v_e_r_s_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     'AsciiToInt' returns 'integer' codes in '0:255' for each (one
     byte) character in 'strings'.  'ichar' is an alias for it, for old
     S compatibility.

     'strcodes' implements in R the basic engine for translating
     characters to corresponding integer codes.

     'chars8bit()' is the _inverse_ function of 'AsciiToint', producing
     (one byte) characters from integer codes.

_U_s_a_g_e:

     AsciiToInt(strings)
          ichar(strings)
     chars8bit(i = 0:255)
     strcodes(x, table = chars8bit(0:255))

_A_r_g_u_m_e_n_t_s:

strings, x: 'character' vector.

       i: numeric (integer) vector of values in '0:255'.

   table: a vector of (unique) character strings, typically of one
          character each.

_D_e_t_a_i_l_s:

     Only codes in '0:127' make up the ASCII encoding which should be
     identical for all R versions, whereas the _'upper'_ half is often
     determined from the ISO-8859-1 (aka "ISO-Latin 1)" encoding, but
     may well differ, depending on the locale setting, see also
     'Sys.setlocale'.

_V_a_l_u_e:

     'AsciiToInt' (and hence 'ichar') and 'chars8bit' return a vector
     of the same length as their argument.

     'strcodes(x, tab)' returns a 'list' of the same 'length' and
     'names' as 'x' with list components of integer vectors with codes
     in '0:255'.

_A_u_t_h_o_r(_s):

     Martin Maechler, partly in 1991 for S-plus

_E_x_a_m_p_l_e_s:

     chars8bit(65:70)#-> "A" "B" .. "F"
     stopifnot(identical(LETTERS,   chars8bit(65:90)),
               identical(AsciiToInt(LETTERS), 65:90))
     ## Not run: 
     ## may only work in ISO-latin1 locale (not in UTF-8):
     strcodes(c(a= "ABC", ch="1234", place = "Zrich"))
     ## gives
     $a
     [1] 65 66 67

     $ch
     [1] 49 50 51 52

     $place
     [1]  90 252 114 105  99 104
     ## End(Not run)

