title: How to fix incorrectly UTF-8 decoded string?
body: <p>I'm consuming data from a RESTful API, it returns me strings and integer values. However, it seems it's returning some string values incorrectly encoded/decoded (probably).</p>
  
  <p>Expected string:</p>
  
  <pre><code>criança
  </code></pre>
  
  <p>String received:</p>
  
  <pre><code>crianÃ§a
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>url = "https://analytics.us.algolia.com/2/searches?index={index}&amp;startDate={yesterday}".format(index=index, yesterday=yesterday)
  headers = { 'X-Algolia-Application-Id': app_id,
              'X-Algolia-API-Key': app_key,
              'Content-Type': 'application/json; charset=utf-8'}
  
  response = requests.get(url, headers=headers)
  response_json = json.loads(response.text)
  
  print(response_json)
  </code></pre>
  
  <p>This is for a Python 3.6.x script that will get data from Algolia's RESTful API and store it in Amazon Redshift. I'm writing this script on Ubuntu 18.04, my Terminal character encoding set is <code>pt_BR.UTF-8</code> (<code>echo $LANG</code>) and UTF-8 (<code>locale charmap</code>).</p>
  
  <p>I see the received data is wrong when I print it before storing it in database - which is set to use <code>charset=utf8</code>. I can also see this wrong data in database, through <code>SELECT</code> statement.</p>
  
  <p>I found this <a href="https://www.i18nqa.com/debug/utf8-debug.html" rel="nofollow noreferrer">UTF-8 Encoding Debugging Chart</a>, it points out that probably it happened because of UTF-8 bytes being interpreted as Windows-1252 (or ISO 8859-1) bytes.</p>
  
  <p>How can I treat it using some Python function/lib?</p>