title: RStudio not picking the encoding I'm telling it to use when reading a file
body: <p>I'm trying to read <a href="https://gist.github.com/mauricio/11347476">the following UTF-8 encoded file</a> in R, but whenever I read it, the unicode characters are not encoded correctly:</p>
  
  <p><img src="https://i.stack.imgur.com/jhOOC.png" alt="enter image description here"></p>
  
  <p>The script I'm using to process the file is as follows:</p>
  
  <pre><code>defaultEncoding &lt;- "UTF8"
  detalheVotacaoMunicipioZonaTypes &lt;- c("character", "character", "factor", "factor", "factor", "factor", "factor",
                                                       "factor", "factor", "factor", "factor", "factor", "numeric", 
                                                       "numeric", "numeric", "numeric", "numeric", "numeric",
                                                       "numeric", "numeric", "numeric", "numeric", "numeric", 
                                                       "numeric", "character", "character")
  
  readDetalheVotacaoMunicipioZona &lt;- function( fileName ) {
    fileConnection = file(fileName,encoding=defaultEncoding)
    contents &lt;- readChar(fileConnection, file.info(fileName)$size)  
    close(fileConnection)
    contents &lt;- gsub('"', "", contents)
  
    columnNames &lt;- c("data_geracao", "hora_geracao", "ano_eleicao", "num_turno", "descricao_eleicao", "sigla_uf", "sigla_ue",
                     "codigo_municipio", "nome_municipio", "numero_zona", "codigo_cargo", "descricao_cargo", "qtd_aptos", 
                     "qtd_secoes", "qtd_secoes_agregadas", "qtd_aptos_tot", "qtd_secoes_tot", "qtd_comparecimento",
                     "qtd_abstencoes", "qtd_votos_nominais", "qtd_votos_brancos", "qtd_votos_nulos", "qtd_votos_legenda", 
                     "qtd_votos_anulados", "data_ult_totalizacao", "hora_ult_totalizacao")
  
    read.csv(text=contents, 
             colClasses=detalheVotacaoMunicipioZonaTypes,
             sep=";", 
             col.names=columnNames, 
             fileEncoding=defaultEncoding,
             header=FALSE)
  }
  </code></pre>
  
  <p>I read the file sending in the UTF-8 encoding, remove all quotes (even numbers are quoted, so I need to clean them up) and then feed the contents to <code>read.csv</code>. It reads and processes the file correctly but it seems like it's not using the encoding information I'm giving it.</p>
  
  <p>What should I do to make it use UTF-8 to read this file?</p>
  
  <p>I'm using RStudio on OSX if it makes any difference.</p>