Java UTF8 Encode toUTF8(String str)

Here you can find the source of toUTF8(String str)

Description

to UTF

License

Apache License

Declaration

public static String toUTF8(String str) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.UnsupportedEncodingException;

public class Main {

    public static String toUTF8(String str) {
        if (!isNull(str)) {
            try {
                str = new String(str.getBytes("ISO8859-1"), "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();/*from w  w  w.ja  v a  2s.com*/
            }
        }
        return str;
    }

    public static boolean isNull(String str) {
        if (null == str || str.length() == 0) {
            return true;
        } else {
            return false;
        }
    }
}

Related

  1. toUTF8(String s)
  2. toUTF8(String sourceStr)
  3. toUTF8(String str)
  4. toUtf8(String str)
  5. toUTF8(String str)
  6. toUTF8(String string)
  7. toUTF8(String value)
  8. toUTF8ByteArray(char[] string)
  9. toUTF8Bytes(final String s)