Here you can find the source of urlEscape(String s)
Parameter | Description |
---|---|
s | String text to encode |
public static String urlEscape(String s)
//package com.java2s; public class Main { /**//w w w . j a va 2s .c om * Do a simple RFC2396 encoding * @param s {@link String} text to encode * @return {@link String} encoded text */ public static String urlEscape(String s) { s = s.replace("%", "%25"); s = s.replace(" ", "%20"); s = s.replace("!", "%21"); s = s.replace("\"", "%22"); s = s.replace("#", "%23"); s = s.replace("$", "%24"); s = s.replace("&", "%26"); s = s.replace("'", "%27"); s = s.replace("(", "%28"); s = s.replace(")", "%29"); s = s.replace("*", "%2A"); s = s.replace("+", "%2B"); s = s.replace(",", "%2C"); s = s.replace(".", "%2E"); s = s.replace("/", "%2F"); s = s.replace(":", "%3A"); s = s.replace(";", "%3B"); s = s.replace("<", "%3C"); s = s.replace("=", "%3D"); s = s.replace(">", "%3E"); s = s.replace("?", "%3F"); s = s.replace("@", "%40"); s = s.replace("[", "%5B"); s = s.replace("\\", "%5C"); s = s.replace("]", "%5D"); s = s.replace("^", "%5E"); s = s.replace("_", "%5F"); s = s.replace("`", "%60"); s = s.replace("{", "%7B"); s = s.replace("|", "%7C"); s = s.replace("}", "%7D"); s = s.replace("~", "%7E"); return s; } }