fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static String encodeUTF8ToLatin(String s) throws UnsupportedEncodingException {
  11. byte[] b = s.getBytes("UTF-8");
  12. return new String(b, "ISO-8859-1");
  13. }
  14.  
  15. public static String encodeLatinToUTF8(String s) throws UnsupportedEncodingException {
  16. byte[] b = s.getBytes("UTF-8");
  17. return new String(b, "UTF-8");
  18. }
  19.  
  20. public static void main (String[] args) throws java.lang.Exception
  21. {
  22. System.out.println(encodeLatinToUTF8("ÅÄÖ åäö"));
  23. }
  24. }
Success #stdin #stdout 0.11s 54776KB
stdin
Standard input is empty
stdout
ÅÄÖ åäö