MCPcopy Index your code
hub / github.com/davidgiven/luje / quoteIllegal

Method quoteIllegal

lib/java/net/URIEncoderDecoder.java:113–135  ·  view source on GitHub ↗

All characters except letters ('a'..'z', 'A'..'Z') and numbers ('0'..'9') and legal characters are converted into their hexidecimal value prepended by '%'. For example: '#' -> %23 Other characters, which are unicode chars that are not US-ASCII, and are not ISO Control or are not ISO Space chars,

(String s, String legal)

Source from the content-addressed store, hash-verified

111 * @return java.lang.String the converted string
112 */
113 static String quoteIllegal(String s, String legal)
114 throws UnsupportedEncodingException {
115 StringBuilder buf = new StringBuilder();
116 for (int i = 0; i < s.length(); i++) {
117 char ch = s.charAt(i);
118 if ((ch >= 'a' && ch <= 'z')
119 || (ch >= 'A' && ch <= 'Z')
120 || (ch >= '0' && ch <= '9')
121 || legal.indexOf(ch) > -1
122 || (ch > 127 && !Character.isSpaceChar(ch) && !Character
123 .isISOControl(ch))) {
124 buf.append(ch);
125 } else {
126 byte[] bytes = new String(new char[] { ch }).getBytes(encoding);
127 for (int j = 0; j < bytes.length; j++) {
128 buf.append('%');
129 buf.append(digits.charAt((bytes[j] & 0xf0) >> 4));
130 buf.append(digits.charAt(bytes[j] & 0xf));
131 }
132 }
133 }
134 return buf.toString();
135 }
136
137 /**
138 * Other characters, which are Unicode chars that are not US-ASCII, and are

Callers 1

quoteComponentMethod · 0.95

Calls 8

isSpaceCharMethod · 0.95
isISOControlMethod · 0.95
appendMethod · 0.95
toStringMethod · 0.95
lengthMethod · 0.65
charAtMethod · 0.65
indexOfMethod · 0.65
getBytesMethod · 0.45

Tested by

no test coverage detected