title: Xstream with special characters
body: <p>I'm working with XStream but I have a problem with the special characters á,é,í,ó,ú and ñ.</p>
  
  <p>I tried this:</p>
  
  <pre><code>  String charset = "UTF-8";
    xstream = new XStream(new DomDriver(charset));
  </code></pre>
  
  <p>(don't work)</p>
  
  <p>I found that <a href="http://x-stream.github.io/faq.html" rel="nofollow">XStream does no character encoding by itself, it relies on the configuration of the underlying XML writer. By default it uses its own PrettyPrintWriter which writes into the default encoding of the current locale. To write UTF-8 you have to provide a Writer with the appropriate encoding yourself.</a></p>
  
  <p>My problem is that I don't know how to provide a Writer...</p>
  
  <pre><code>// get the model from the map passed created by the controller
  Object model = map.get("model");
  
  Object viewData = transformViewData(model);
  
  //TEST
  Writer w = new OutputStreamWriter(viewData, "UTF-8");
  //FINTEST
  
  // if the model is null, we have an exception
  String xml = null;
  if (viewData != null){
      xml = xstream.toXML(viewData, w);  //Err:Cannot find symbol...
  }else{
      // so render entire map
      xml = xstream.toXML(map, w); //Err:Cannot find symbol...
  }
  
  response.getOutputStream().write(xml.getBytes());
  </code></pre>