title: Convert ISO-8859-1 to UTF-8 using groovy
body: <p>i need to convert a ISO-8859-1 file to utf-8 encoding, without loosing content intormations...</p>
  
  <p>i have a file which looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt; 
  &lt;HelloEncodingWorld&gt;Üöäüßßß Test!!!&lt;/HelloEncodingWorld&gt;
  </code></pre>
  
  <p>Not i want to encode it into UTF-8.
  I tried following:</p>
  
  <pre><code>f=new File('c:/temp/myiso88591.xml').getText('ISO-8859-1')
  ts=new String(f.getBytes("UTF-8"), "UTF-8")
  g=new File('c:/temp/myutf8.xml').write(ts)
  </code></pre>
  
  <p>didnt work due to String incompatibilities.
  Then i read something about bytestreamreaders/writers/streamingmarkupbuilder and other...</p>
  
  <p>then i tried </p>
  
  <pre><code>f=new File('c:/temp/myiso88591.xml').getText('ISO-8859-1')
  mb = new groovy.xml.StreamingMarkupBuilder()
  mb.encoding = "UTF-8"
  
  new OutputStreamWriter(new FileOutputStream('c:/temp/myutf8.xml'),'utf-8') &lt;&lt; mb.bind {
      mkp.xmlDeclaration()
      out &lt;&lt; f
  }
  </code></pre>
  
  <p>this was totally not that what i wanted..</p>
  
  <p>I just want to get the content of an xml read with an ISO-8859-1 reader and then put it into a new (old) file... why this is so complicated :-/</p>
  
  <p>The result should just be, and the file should be really encoded in utf-8:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; 
  &lt;HelloEncodingWorld&gt;Üöäüßßß Test!!!&lt;/HelloEncodingWorld&gt;
  </code></pre>
  
  <p>Thanks for any answers
  Cheers</p>