Java UTF8 Encode toUTF8(String str)

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

Description

to UTF

License

Open Source License

Declaration

public static String toUTF8(String str) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.UnsupportedEncodingException;

import java.net.URLEncoder;

public class Main {
    public static String toUTF8(String str) {
        try {//  w  w w  .  ja va 2 s.com
            return URLEncoder.encode(str, "UTF-8").replace("%2F", "/")
                    .replace("+", " ");
        } catch (UnsupportedEncodingException ex) {
            return str;
        }
    }
}

Related

  1. toUTF8(byte[] bytes)
  2. toUTF8(String content)
  3. toUTF8(String isoString)
  4. toUTF8(String s)
  5. toUTF8(String sourceStr)
  6. toUTF8(String str)
  7. toUtf8(String str)
  8. toUTF8(String str)
  9. toUTF8(String string)