Java UTF from toUtf8String(String source)

Here you can find the source of toUtf8String(String source)

Description

to Utf String

License

Apache License

Declaration

public static String toUtf8String(String source) throws UnsupportedEncodingException 

Method Source Code

//package com.java2s;
/*/*  ww  w  .jav a2 s.c  om*/
 * BJAF - Beetle J2EE Application Framework
 * ???J2EE???????????
 * ??????2003-2015 ??? (www.beetlesoft.net)
 * 
 * ??????????????????
 *<http://www.apache.org/licenses/LICENSE-2.0>
 *????????????????????????
 *
 * ???????????????????????????????
 * ??? <yuhaodong@gmail.com/>.
 */

import java.io.UnsupportedEncodingException;

public class Main {

    public static String toUtf8String(String source) throws UnsupportedEncodingException {
        if (source == null) {
            return null;
        }
        if (source.equals(new String(source.getBytes("ISO-8859-1"), "ISO-8859-1"))) {
            return new String(source.getBytes("ISO-8859-1"), "UTF-8");
        }
        return source;
    }
}

Related

  1. toUtf8Codes(String str)
  2. toUTF8FromLatin1(byte[] outputBuffer, String string)
  3. toUTF8k(String in)
  4. toUtf8Path(String path)
  5. toUTF8String(byte[] b, int offset, int length)
  6. toUTF8String(String str)
  7. toUTF_8(String s)
  8. toUTFBody(String str)
  9. toUtfBytes(final String s)