title: Encoding problems on MAC
body: <p>I'm trying to download a file and load into R, but It's not working. 
  I'm on a MAC, using R 3.1.3</p>
  
  <p>The file is in csv format (and there's an option of json format).</p>
  
  <p>Here's the url for the file (csv and json):
  <a href="http://dadosabertos.dataprev.gov.br/opendata/con02/formato=csv" rel="nofollow">http://dadosabertos.dataprev.gov.br/opendata/con02/formato=csv</a>
  <a href="http://dadosabertos.dataprev.gov.br/opendata/con02/formato=json" rel="nofollow">http://dadosabertos.dataprev.gov.br/opendata/con02/formato=json</a></p>
  
  <p>I know I can download the file, open in a local text editor, save as utf-8, and then import into R. But I'd like a more automated solution, that didn't involve using another software. And, btw, even this solution isn't working as easy as I expected.</p>
  
  <p>Here's what I tried so far:
  Since the file is in Portuguese, I know it's probably utf-8. </p>
  
  <pre><code>library(jsonlite)
  options(encoding = "utf-8")
  url &lt;- "http://dadosabertos.dataprev.gov.br/opendata/con02/formato=json"
  prev &lt;- fromJSON(url)
  </code></pre>
  
  <p>And the error message:</p>
  
  <p>lexical error: invalid bytes in UTF8 string.
            :[{"node":{"Ano":"1988","Esp�cie":"42-Ap Tempo Contribui��o 
                       (right here) ------^</p>
  
  <p>I also tried
  url1 &lt;- "<a href="http://dadosabertos.dataprev.gov.br/opendata/con02/formato=csv" rel="nofollow">http://dadosabertos.dataprev.gov.br/opendata/con02/formato=csv</a>"
  prev &lt;- read.csv(url, sep=",")</p>
  
  <p>But it also didn't work. I tried also to use:</p>
  
  <pre><code>Sys.setlocale("LC_ALL", 'en_US.UTF-8')
  </code></pre>
  
  <p>But it didn't make any difference.</p>