Translates a string into x-www-form-urlencoded format. @param s String to be translated. @return the translated String .
(String s)
| 561 | * @return the translated <code>String</code>. |
| 562 | */ |
| 563 | static String encode(String s) { |
| 564 | if (s == null) |
| 565 | return null; |
| 566 | // the common case is no encoding is needed |
| 567 | for (int i = 0; i < s.length(); i++) { |
| 568 | int c = (int)s.charAt(i); |
| 569 | if (c == ' ' || !dontNeedEncoding.get(c)) |
| 570 | return _encode(s); |
| 571 | } |
| 572 | return s; |
| 573 | } |
| 574 | |
| 575 | private static String _encode(String s) { |
| 576 | int maxBytesPerChar = 10; |