Java String Encode encodeUTF8(String s)

Here you can find the source of encodeUTF8(String s)

Description

encode UTF

License

LGPL

Declaration

public static String encodeUTF8(String s) 

Method Source Code

//package com.java2s;

import java.net.URLEncoder;

public class Main {

    public static String encodeUTF8(String s) {
        try {/*w  w w .java  2s. co  m*/
            if (s == null || s.equals(""))
                return "";
            s = URLEncoder.encode(s, "UTF-8");
            s = s.replaceAll("\\+", "%20");
            return s;
        } catch (Exception e) {
            e.printStackTrace();
            return s;
        }
    }
}

Related

  1. encodeToFlex(Object o)
  2. encodeToForm(Map msg)
  3. encodeToString(String s)
  4. encodeURNComponent(String value)
  5. encodeUTF8(String input, boolean keepSpaces)
  6. encodeUTF8(String s)
  7. encodeValue(String dirtyValue)
  8. encodeValue(String str)
  9. encodeValue(String value)