LEFT | RIGHT |
1 /* | 1 /* |
2 * Copyright (c) 2010 Google Inc. | 2 * Copyright (c) 2010 Google Inc. |
3 * | 3 * |
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.apache.org/licenses/LICENSE-2.0 | 7 * http://www.apache.org/licenses/LICENSE-2.0 |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
11 * or implied. See the License for the specific language governing permissions a
nd limitations under | 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
12 * the License. | 12 * the License. |
13 */ | 13 */ |
14 | 14 |
15 package com.google.api.client.util.escape; | 15 package com.google.api.client.util.escape; |
16 | 16 |
17 /** | 17 /** |
18 * A {@code UnicodeEscaper} that escapes some set of Java characters using the U
RI percent encoding | 18 * A {@code UnicodeEscaper} that escapes some set of Java characters using the U
RI percent encoding |
19 * scheme. The set of safe characters (those which remain unescaped) can be spec
ified on | 19 * scheme. The set of safe characters (those which remain unescaped) can be spec
ified on |
20 * construction. | 20 * construction. |
21 * | 21 * |
22 * <p> | 22 * <p> |
23 * For details on escaping URIs for use in web pages, see <a | 23 * For details on escaping URIs for use in web pages, see <a |
24 * href="http://tools.ietf.org/html/rfc3986#section-2.4">RFC 3986 - section 2.4<
/a> and <a | 24 * href="http://tools.ietf.org/html/rfc3986#section-2.4">RFC 3986 - section 2.4<
/a> and <a |
25 * href="http://tools.ietf.org/html/rfc3986#appendix-A">RFC 3986 - Appendix A</a
> | 25 * href="http://tools.ietf.org/html/rfc3986#appendix-A">RFC 3986 - appendix A</a
> |
26 * | 26 * |
27 * <p> | 27 * <p> |
28 * When encoding a String, the following rules apply: | 28 * When encoding a String, the following rules apply: |
29 * <ul> | 29 * <ul> |
30 * <li>The alphanumeric characters "a" through "z", "A" through "Z" and "0" thro
ugh "9" remain the | 30 * <li>The alphanumeric characters "a" through "z", "A" through "Z" and "0" thro
ugh "9" remain the |
31 * same. | 31 * same. |
32 * <li>Any additionally specified safe characters remain the same. | 32 * <li>Any additionally specified safe characters remain the same. |
33 * <li>If {@code plusForSpace} was specified, the space character " " is convert
ed into a plus sign | 33 * <li>If {@code plusForSpace} was specified, the space character " " is convert
ed into a plus sign |
34 * "+". | 34 * "+". |
35 * <li>All other characters are converted into one or more bytes using UTF-8 enc
oding and each byte | 35 * <li>All other characters are converted into one or more bytes using UTF-8 enc
oding and each byte |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 dest[4] = UPPER_HEX_DIGITS[0x8 | cp & 0x3]; | 262 dest[4] = UPPER_HEX_DIGITS[0x8 | cp & 0x3]; |
263 cp >>>= 2; | 263 cp >>>= 2; |
264 dest[2] = UPPER_HEX_DIGITS[cp & 0x7]; | 264 dest[2] = UPPER_HEX_DIGITS[cp & 0x7]; |
265 return dest; | 265 return dest; |
266 } else { | 266 } else { |
267 // If this ever happens it is due to bug in UnicodeEscaper, not bad input. | 267 // If this ever happens it is due to bug in UnicodeEscaper, not bad input. |
268 throw new IllegalArgumentException("Invalid unicode character value " + cp
); | 268 throw new IllegalArgumentException("Invalid unicode character value " + cp
); |
269 } | 269 } |
270 } | 270 } |
271 } | 271 } |
LEFT | RIGHT |