/** * Strips #x00 - #x1F and #x7F-#x9F from a Unicode string * @see <a href="http://www.w3.org/TR/rdf-concepts/#dfn-URI-reference"> * http://www.w3.org/TR/rdf-concepts/#dfn-URI-reference</a> and * replaces all US-ASCII space character with a "+". * * @param inputChars * @return the stripped string * */ public static String stripNonIRIChars(CharSequence inputChars) { if (inputChars == null) { return ""; } StringBuffer buffer = new StringBuffer(); for (int i = 0; i < inputChars.length(); i++) { char c = inputChars.charAt(i); if (!isIllegal(c)) { buffer.append(c); } } return buffer.toString().replaceAll("\\s+", "+"); }
/** * Strips #x00 - #x1F and #x7F-#x9F from a Unicode string * @see <a href="http://www.w3.org/TR/rdf-concepts/#dfn-URI-reference"> * http://www.w3.org/TR/rdf-concepts/#dfn-URI-reference</a> and * replaces all US-ASCII space character with a "+". * * @param inputChars * @return the stripped string * */ public static String stripNonIRIChars(CharSequence inputChars) { if (inputChars == null) { return ""; } StringBuffer buffer = new StringBuffer(); for (int i = 0; i < inputChars.length(); i++) { char c = inputChars.charAt(i); if (!isIllegal(c)) { buffer.append(c); } } return buffer.toString().replaceAll("\\s+", "+"); }