title: UTF-8 GET using Indy 10.5.8.0 and Delphi XE2
body: <p>I'm writing my first Unicode application with Delphi XE2, and I've stumbled upon an issue with <code>GET</code> requests to a Unicode URL.</p>
  
  <p>In short, it's a routine in a MP3 tagging application that takes a track title and an artist, and queries Last.FM for the corresponding album, track number, and genre.</p>
  
  <p>I have the following code: </p>
  
  <pre><code>function GetMP3Info(artist, track: string) : TMP3Data //&lt;---(This is a record)
  var
    TrackTitle,
    ArtistTitle : WideString;
    webquery    : WideString;
  
  [....]
  
  WebQuery := UTF8Encode('http://ws.audioscrobbler.com/2.0/?method=track.getcorrection&amp;api_key=' + apikey + '&amp;artist=' + artist + '&amp;track=' + track);
  
  //[processing the result in the web query, getting the correction for the artist and title]
  
  // eg: for artist := Bucovina and track := Mestecanis, the corrected values are 
  //ArtistTitle := Bucovina;
  // TrackTitle := Mestecăniș;
  
  //Now here is the tricky part:
  
  webquery := UTF8Encode('http://ws.audioscrobbler.com/2.0/?method=track.getInfo&amp;api_key=' + apikey + '&amp;artist=' + unescape(ArtistTitle) + '&amp;track=' + unescape(TrackTitle)); 
  //the unescape function replaces spaces (' ') with '+' to comply with the last.fm requests
  
  [some more processing]
  
  end;
  </code></pre>
  
  <p>The webquery in a <code>TMemo</code> looks just right:</p>
  
  <blockquote>
    <p><a href="http://ws.audioscrobbler.com/2.0/?method=track.getInfo&amp;api_key=e5565002840xxxxxxxxxxxxxx23b98ad&amp;artist=Bucovina&amp;track=Mestec%C4%83ni%C8%99" rel="nofollow noreferrer">http://ws.audioscrobbler.com/2.0/?method=track.getInfo&amp;api_key=e5565002840xxxxxxxxxxxxxx23b98ad&amp;artist=Bucovina&amp;track=Mestecăniș</a></p>
  </blockquote>
  
  <p>Yet, when I try to send a <code>GET</code> request to the webquery using <code>TIdHTTP</code> (with the <code>ContentEncoding</code> property set to <code>'UTF-8'</code>), I see in Wireshark that <code>TIdHTTP</code> is <code>GET</code>'ing data using an ANSI request URL:</p>
  
  <blockquote>
    <p>/2.0/?method=track.getInfo&amp;api_key=e5565002840xxxxxxxxxxxxxx23b98ad&amp;artist=Bucovina&amp;track=Mestec?ni?</p>
  </blockquote>
  
  <p>Here are the full headers for the <code>GET</code> requests and responses:</p>
  
  <pre><code>GET /2.0/?method=track.getInfo&amp;api_key=e5565002840xxxxxxxxxxxxxx23b98ad&amp;artist=Bucovina&amp;track=Mestec?ni? HTTP/1.1
  Content-Encoding: UTF-8
  Host: ws.audioscrobbler.com
  Accept: text/html, */*
  Accept-Encoding: identity
  User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.23) Gecko/20110920 Firefox/3.6.23 SearchToolbar/1.22011-10-16 20:20:07
  
  HTTP/1.0 400 Bad Request
  Date: Tue, 09 Oct 2012 20:46:31 GMT
  Server: Apache/2.2.22 (Unix)
  X-Web-Node: www204
  Access-Control-Allow-Origin: *
  Access-Control-Allow-Methods: POST, GET, OPTIONS
  Access-Control-Max-Age: 86400
  Cache-Control: max-age=10
  Expires: Tue, 09 Oct 2012 20:46:42 GMT
  Content-Length: 114
  Connection: close
  Content-Type: text/xml; charset=utf-8;
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;lfm status="failed"&gt;
  &lt;error code="6"&gt;
      Track not found
  &lt;/error&gt;
  &lt;/lfm&gt;
  </code></pre>
  
  <p>The question that puzzles me is, am I overseeing anything related to setting the properties of the <code>TIdHTTP</code> component? How can I stop the well-formatted URL I'm composing in the application from getting sent to the server in the wrong format?</p>