title: Javascript: convert CSV string into a) UTF-8 and b) a 2D array
body: <p>Two questions in one, not sure if that's allowed, but they're directly related to the same code.
  I retrieve a CSV string as a HTTP response in Javascript - this string comes in UTF-16 encoding it seems, as it has for example ' â‚¬ ' instead of '€'.</p>
  
  <p>a) How can I convert this to UTF-8 in vanilla Javascript?</p>
  
  <p>Once that's done, how do I 
  b) transform the multi-line CSV into a 2D array in vanilla Javascript?</p>
  
  <p>Thanks!</p>
  
  <hr>
  
  <p>[UPDATE]</p>
  
  <p>Based on anqooqie's pointers, I take the following approach to re-encode the string:</p>
  
  <p>OK, clear - so to be honest, I went a slightly different way (as the reencode function didn't work for me and it threw a generic error code) and now do the below;</p>
  
  <pre><code>var O = new ActiveXObject('ADODB.Stream');
  O.Type = 2; 
  O.Open;
  O.Charset = 'ISO-8859-1';
  O.LineSeparator = 10;
  O.WriteText (csvStr);
  O.Position = 0;
  O.Charset = 'UTF-8';
  </code></pre>
  
  <p>And this works fine and in pretty much a split second (even though it's a 35K row CSV). Now if I want to put it back into the csvStr, I would do</p>
  
  <pre><code>csvStr = O.ReadText
  </code></pre>
  
  <p>but this takes ages - is that expected or am I doing something wrong?</p>
  
  <p>For putting it into a 2D array, I split on the LineSeparator and then loop using a regex, which seems to work. </p>
  
  <pre><code>var A = new Array
  A.push(csvStr[0].match(/"[^"]*"|[^,]+/g))
  </code></pre>
  
  <p>The vast delay on the readText is bothering me though, especially as the WriteText is so quick. Any help is appreciated.</p>