/** Encode using the rules for a component (e.g. ':' and '/' get encoded) * Does not encode non-ASCII characters */ public static String encodeUriComponent(String string) { String encStr = StrUtils.encodeHex(string,'%', charsComponent) ; return encStr ; }
/** Encode using the rules for a file: URL. * Does not encode non-ASCII characters */ public static String encodeFileURL(String string) { String encStr = StrUtils.encodeHex(string,'%', charsFilename) ; return encStr ; }
/** Encode using the rules for a component (e.g. ':' and '/' get encoded) * Does not encode non-ASCII characters */ public static String encodeUriComponent(String string) { String encStr = StrUtils.encodeHex(string,'%', charsComponent) ; return encStr ; }
/** Encode using the rules for a component (e.g. ':' and '/' get encoded) * Does not encode non-ASCII characters */ public static String encodeUriComponent(String string) { String encStr = StrUtils.encodeHex(string,'%', charsComponent) ; return encStr ; }
/** Encode using the rules for a path (e.g. ':' and '/' do not get encoded) */ public static String encodeUriPath(String uri) { // Not perfect. // Encode path. // %-encode chars. uri = StrUtils.encodeHex(uri, '%', charsPath) ; return uri ; }
/** Encode using the rules for a file: URL. * Does not encode non-ASCII characters */ public static String encodeFileURL(String string) { String encStr = StrUtils.encodeHex(string,'%', charsFilename) ; return encStr ; }
/** Encode using the rules for a path (e.g. ':' and '/' do not get encoded) */ public static String encodeUriPath(String uri) { // Not perfect. // Encode path. // %-encode chars. uri = StrUtils.encodeHex(uri, '%', charsPath) ; return uri ; }
/** Encode using the rules for a path (e.g. ':' and '/' do not get encoded) */ public static String encodeUriPath(String uri) { // Not perfect. // Encode path. // %-encode chars. uri = StrUtils.encodeHex(uri, '%', charsPath) ; return uri ; }
/** Encode using the rules for a file: URL. * Does not encode non-ASCII characters */ public static String encodeFileURL(String string) { String encStr = StrUtils.encodeHex(string,'%', charsFilename) ; return encStr ; }
public static void main(String...args) { // Reserved characters + space char reserved[] = {' ', '\n','\t', '!', '*', '"', '\'', '(', ')', ';', ':', '@', '&', '=', '+', '$', ',', '/', '?', '%', '#', '[', ']'} ; char[] other = {'<', '>', '~', '.', '{', '}', '|', '\\', '-', '`', '_', '^'} ; for ( String x : args) { // Not URLEncoder which does www-form-encoding. String y = StrUtils.encodeHex(x, '%', reserved) ; System.out.println(y) ; // String s2 = URLEncoder.encode(s, "utf-8") ; // System.out.println(s2) ; } } }
public static void main(String...args) throws IOException { // Reserved characters + space char reserved[] = {' ', '\n','\t', '!', '*', '"', '\'', '(', ')', ';', ':', '@', '&', '=', '+', '$', ',', '/', '?', '%', '#', '[', ']'} ; char[] other = {'<', '>', '~', '.', '{', '}', '|', '\\', '-', '`', '_', '^'} ; if ( args.length == 0 ) { String x = IO.readWholeFileAsUTF8(System.in); String y = StrUtils.encodeHex(x, '%', reserved) ; System.out.println(y) ; return; } for ( String x : args) { // Not URLEncoder which does www-form-encoding. String y = StrUtils.encodeHex(x, '%', reserved) ; System.out.println(y) ; // String s2 = URLEncoder.encode(s, "utf-8") ; // System.out.println(s2) ; } } }
public static void main(String...args) throws IOException { // Reserved characters + space char reserved[] = {' ', '\n','\t', '!', '*', '"', '\'', '(', ')', ';', ':', '@', '&', '=', '+', '$', ',', '/', '?', '%', '#', '[', ']'} ; char[] other = {'<', '>', '~', '.', '{', '}', '|', '\\', '-', '`', '_', '^'} ; if ( args.length == 0 ) { String x = IO.readWholeFileAsUTF8(System.in); String y = StrUtils.encodeHex(x, '%', reserved) ; System.out.println(y) ; return; } for ( String x : args) { // Not URLEncoder which does www-form-encoding. String y = StrUtils.encodeHex(x, '%', reserved) ; System.out.println(y) ; // String s2 = URLEncoder.encode(s, "utf-8") ; // System.out.println(s2) ; } } }
static void test(String x, String z) { String y = StrUtils.encodeHex(x, marker, esc) ; if ( z != null ) assertEquals(z, y) ; String x2 = StrUtils.decodeHex(y, marker) ; assertEquals(x, x2) ; }
private /*public*/ static String encode(Node node, PrefixMapping pmap) { if ( node.isBlank() ) // Raw label. return "_:"+node.getBlankNodeLabel() ; if ( node.isURI() ) { // Pesky spaces //throw new TDBException("Space found in URI: "+node) ; String x = StrUtils.encodeHex(node.getURI(), '_', invalidIRIChars) ; if ( x != node.getURI() ) node = NodeFactory.createURI(x) ; } return NodeFmtLib.str(node) ; }
String x = StrUtils.encodeHex(node.getURI(), MarkerChar, invalidIRIChars) ; if ( x != node.getURI() ) node = NodeFactory.createURI(x) ;