title: Adding a console output to Swing gui that can support special characters
body: <p>My application has a console where all the system's printstream content is rerouted to. </p>
  
  <p>My application will also output special characters, specifically other languages (asian languages, Russian, Arabic, etc) </p>
  
  <p>I'm using a JTextArea as the console out:</p>
  
  <pre><code>    consoleOutput = new JTextArea(1, 50);
  
      DefaultCaret caret = (DefaultCaret) consoleOutput.getCaret();
      caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
  
      Font font = new Font("Consolas", Font.PLAIN, 12);
      consoleOutput.setFont(font);
  
      JScrollPane scrollPane = new JScrollPane(consoleOutput);
      this.add(scrollPane, BorderLayout.CENTER);
  
  
      //CHANGE OUTPUT TO THIS CONSOLE
      PrintStream out = new PrintStream(new TextAreaOutput(consoleOutput));
  
      System.setOut(out);
      System.setErr(out);
  </code></pre>
  
  <p>And this class to rerout the printstream:</p>
  
  <pre><code>public class TextAreaOutput extends OutputStream {
      JTextArea outputConsole;
  
      public TextAreaOutput(JTextArea outputConsole) {
          this.outputConsole = outputConsole;
      }
  
      @Override
      public void write(int b) throws IOException {
          outputConsole.append( String.valueOf( ( char )b ) );
      }
  }
  </code></pre>
  
  <p>This works and the printstream prints to this jtextarea. However, I have encoding issues. Special characters like <code>▒, █, .نت, 览, etc</code> do not render correctly. Some might be hardcoded into source files (I'm using UTF-8), but some might be extracted from the web with selenium webdriver.</p>