Here you can find the source of encodeURNComponent(String value)
Parameter | Description |
---|---|
value | value |
public static String encodeURNComponent(String value)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { /**// w ww . java 2s .c o m * Encode data to URN fragment. * <br/><b>NOTE:</b> similar to JavaScript's encodeURIComponent for basic ascii set * * @param value value * @return encoded urn fragment */ public static String encodeURNComponent(String value) { try { return URLEncoder.encode(value, "UTF-8").replace("+", "%20").replace("%21", "!").replace("%27", "\'") .replace("%28", "(").replace("%29", ")").replace("%7E", "~"); } catch (UnsupportedEncodingException e) { // must not happen, utf-8 is part of java spec throw new IllegalStateException(e); } } }