| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Javascript-like URI encode/decode functions. | 6 * Javascript-like URI encode/decode functions. |
| 7 * The documentation here borrows heavily from the original Javascript | 7 * The documentation here borrows heavily from the original Javascript |
| 8 * doumentation on MDN at: | 8 * doumentation on MDN at: |
| 9 * https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects | 9 * https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects |
| 10 */ | 10 */ |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 /** | 104 /** |
| 105 * Convert a byte (2 character hex sequence) in string [s] starting | 105 * Convert a byte (2 character hex sequence) in string [s] starting |
| 106 * at position [pos] to its ordinal value | 106 * at position [pos] to its ordinal value |
| 107 */ | 107 */ |
| 108 | 108 |
| 109 int _hexCharPairToByte(String s, int pos) { | 109 int _hexCharPairToByte(String s, int pos) { |
| 110 // An alternative to calling parseInt twice would be to take a | 110 // An alternative to calling parseInt twice would be to take a |
| 111 // two character substring and call it once, but that may be less | 111 // two character substring and call it once, but that may be less |
| 112 // efficient. | 112 // efficient. |
| 113 int d1 = Math.parseInt("0x${s[pos]}"); | 113 int d1 = parseInt("0x${s[pos]}"); |
| 114 int d2 = Math.parseInt("0x${s[pos+1]}"); | 114 int d2 = parseInt("0x${s[pos+1]}"); |
| 115 return d1 * 16 + d2; | 115 return d1 * 16 + d2; |
| 116 } | 116 } |
| 117 | 117 |
| 118 /** | 118 /** |
| 119 * A JavaScript-like decodeURI function. It unescapes the string [text] and | 119 * A JavaScript-like decodeURI function. It unescapes the string [text] and |
| 120 * returns the unescaped string. | 120 * returns the unescaped string. |
| 121 */ | 121 */ |
| 122 String _uriDecode(String text) { | 122 String _uriDecode(String text) { |
| 123 StringBuffer result = new StringBuffer(); | 123 StringBuffer result = new StringBuffer(); |
| 124 List<int> codepoints = new List<int>(); | 124 List<int> codepoints = new List<int>(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 138 if (i == text.length) | 138 if (i == text.length) |
| 139 break; | 139 break; |
| 140 ch = text[i]; | 140 ch = text[i]; |
| 141 } | 141 } |
| 142 result.add(decodeUtf8(codepoints)); | 142 result.add(decodeUtf8(codepoints)); |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 return result.toString(); | 145 return result.toString(); |
| 146 } | 146 } |
| 147 | 147 |
| OLD | NEW |