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

Method encodeOthers

lib/java/net/URIEncoderDecoder.java:150–166  ·  view source on GitHub ↗

Other characters, which are Unicode chars that are not US-ASCII, and are not ISO Control or are not ISO Space chars are not preserved. They are converted into their hexidecimal value prepended by '%'. For example: Euro currency symbol -> "%E2%82%AC". Called from URI.toASCIIString() @param s

(String s)

Source from the content-addressed store, hash-verified

148 * @return java.lang.String the converted string
149 */
150 static String encodeOthers(String s) throws UnsupportedEncodingException {
151 StringBuilder buf = new StringBuilder();
152 for (int i = 0; i < s.length(); i++) {
153 char ch = s.charAt(i);
154 if (ch <= 127) {
155 buf.append(ch);
156 } else {
157 byte[] bytes = new String(new char[] { ch }).getBytes(encoding);
158 for (int j = 0; j < bytes.length; j++) {
159 buf.append('%');
160 buf.append(digits.charAt((bytes[j] & 0xf0) >> 4));
161 buf.append(digits.charAt(bytes[j] & 0xf));
162 }
163 }
164 }
165 return buf.toString();
166 }
167
168 /**
169 * Decodes the string argument which is assumed to be encoded in the {@code

Callers 1

encodeOthersMethod · 0.95

Calls 5

appendMethod · 0.95
toStringMethod · 0.95
lengthMethod · 0.65
charAtMethod · 0.65
getBytesMethod · 0.45

Tested by

no test coverage detected