title: Java convert encoding
body: <p>I have a string which used to be an xml tag where mojibakes are contained:<br>
  <code>&lt;Applicant_Place_Born&gt;Ð&amp;#156;Ð¾Ñ&amp;#129;ÐºÐ²Ð°&lt;/Applicant_Place_Born&gt;</code></p>
  
  <p>I know that exactly the same string but in correct encoding is: <br>
  <code>&lt;Applicant_Place_Born&gt;Москва&lt;/Applicant_Place_Born&gt;</code></p>
  
  <p>I know this because using Tcl utility I can convert it into proper string:</p>
  
  <pre><code># The original string
  set s "Ð&amp;#156;Ð¾Ñ&amp;#129;ÐºÐ²Ð°"
  # substituting the html escapes
  set t "Ð\x9cÐ¾Ñ\x81ÐºÐ²Ð°"
  # decode from utf-8 into Unicode
  encoding convertfrom utf-8 "Ð\x9cÐ¾Ñ\x81ÐºÐ²Ð°"
  Москва
  </code></pre>
  
  <p>I tried different variations of this:</p>
  
  <pre><code>System.out.println(new String(original.getBytes("UTF-8"), "CP1251"));
  </code></pre>
  
  <p>but I always got other mojibakes or question marks instead of characters.</p>
  
  <p><strong>Q: How can I do the same as Tcl does but using Java code?</strong></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I have tried @Joop Eggen's approach:</p>
  
  <pre><code>import org.apache.commons.lang3.StringEscapeUtils;
  
  
  public class s {
      static String s;
      public static void main(String[] args) {
          try {
              System.setProperty("file.encoding", "CP1251");
              System.out.println("JVM encoding: " + System.getProperty("file.encoding"));
              s = "Ð&amp;#156;Ð¾Ñ&amp;#129;ÐºÐ²Ð°";
              System.out.println("Original text: " + s);
  
              s = StringEscapeUtils.unescapeHtml4(s);
              byte[] b = s.getBytes(StandardCharsets.ISO_8859_1);
              s = new String(b, "UTF-16BE");
  
              System.out.println("Result: " + s);
  
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
      }
  }
  </code></pre>
  
  <p>The converted string was something Chineese:</p>
  
  <p><code>JVM encoding: CP1251
  Original text: Ð&amp;#156;Ð¾Ñ&amp;#129;ÐºÐ²Ð°
  Result: 킜킾톁킺킲킰</code></p>