title: Text encoding translation in clojure
body: <p>I'd like to write a clojure function that takes a string in one encoding and converts it to another. The iconv library does this. </p>
  
  <p>For example, let's look at the character "è". In ISO-8859-1 (<a href="http://www.ascii-code.com/" rel="noreferrer">http://www.ascii-code.com/</a>), that's <code>e8</code> as hex. In UTF-8 (<a href="http://www.ltg.ed.ac.uk/~richard/utf-8.cgi?input=%C3%A8&amp;mode=char" rel="noreferrer">http://www.ltg.ed.ac.uk/~richard/utf-8.cgi?input=%C3%A8&amp;mode=char</a>), it's <code>c3 a8</code>.</p>
  
  <p>So let's say we have iso.txt, which contains our letter and EOL:</p>
  
  <pre><code>$ hexdump iso.txt                               
  0000000 e8 0a                  
  0000002
  </code></pre>
  
  <p>Now we can convert it to UTF-8 like this:</p>
  
  <pre><code>$ iconv -f ISO-8859-1 -t UTF-8 iso.txt | hexdump
  0000000 c3 a8 0a                                       
  0000003
  </code></pre>
  
  <p>How should I write something equivalent in clojure? I'm happy to use any external libraries, but I don't know where I'd go to find them. Looking around I couldn't figure out how to use libiconv itself on the JVM, but there's probably an alternative?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>After reading Alex's link in the comment, this is so simple and so cool:</p>
  
  <pre><code>user&gt; (new String (byte-array 2 (map unchecked-byte [0xc3 0xa8])) "UTF-8")
  "è"
  
  user&gt; (new String (byte-array 1 [(unchecked-byte 0xe8)]) "ISO-8859-1")
  "è"
  </code></pre>