title: Print String with escape non printable characters
body: <p>I have this String</p>
  
  <pre><code>String x="String containning special chars  \u202C \n  \u202C  \u202C  \u202C";
  </code></pre>
  
  <p>How can I print out this: <code>String containning special chars  \u202C \n  \u202C  \u202C  \u202C</code> ?</p>
  
  <p>Tried </p>
  
  <pre><code>System.out.println(x.replace("\\","\\\\"));
  </code></pre>
  
  <p>But that only prints <code>String containning special chars  ‬ \n ‬  ‬  ‬</code></p>
  
  <p>Also tried </p>
  
  <pre><code>String out = org.apache.commons.lang3.StringEscapeUtils.unescapeJava(x);
  System.out.println(out);
  </code></pre>
  
  <p>But that also doesn't help.</p>
  
  <p>Any one with a suggestion or an API that I am not aware of?</p>
  
  <p><strong>UPDATE - SOLUTION</strong></p>
  
  <p>Following @lbear aproach I came up with this functions that deals most cases of escaped Strings</p>
  
  <pre><code>public static String removeUnicodeAndEscapeChars(String input) {
      StringBuilder buffer = new StringBuilder(input.length());
      for (int i = 0; i &lt; input.length(); i++) {
          if ((int) input.charAt(i) &gt; 256) {
              buffer.append("\\u").append(Integer.toHexString((int) input.charAt(i)));
          } else {
              if (input.charAt(i) == '\n') {
                  buffer.append("\\n");
              } else if(input.charAt(i) == '\t'){
                  buffer.append("\\t");
              }else if(input.charAt(i) == '\r'){
                  buffer.append("\\r");
              }else if(input.charAt(i) == '\b'){
                  buffer.append("\\b");
              }else if(input.charAt(i) == '\f'){
                  buffer.append("\\f");
              }else if(input.charAt(i) == '\''){
                  buffer.append("\\'");
              }else if(input.charAt(i) == '\"'){
                  buffer.append("\\");
              }else if(input.charAt(i) == '\\'){
                  buffer.append("\\\\");
              }else {
                  buffer.append(input.charAt(i));
              }
          }
      }
      return buffer.toString();
  }
  </code></pre>