Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: sdk/lib/uri/encode_decode.dart

Issue 11368138: Add some support for the code-point code-unit distinction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Implemented feedback from patch set 3 Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/uri/encode_decode.dart
diff --git a/sdk/lib/uri/encode_decode.dart b/sdk/lib/uri/encode_decode.dart
index 6338518a4a5a290b2dbfe959912ccbbeb07ffbc4..09473f23ca515101d738ebe15ec731c1a3d39ab0 100644
--- a/sdk/lib/uri/encode_decode.dart
+++ b/sdk/lib/uri/encode_decode.dart
@@ -77,22 +77,13 @@ String _uriEncode(String canonical, String text) {
final String hex = '0123456789ABCDEF';
var byteToHex = (int v) => '%${hex[v >> 4]}${hex[v&0xf]}';
StringBuffer result = new StringBuffer();
+ // TODO(erikcorry): Use the new character iterator.
for (int i = 0; i < text.length; i++) {
if (canonical.indexOf(text[i]) >= 0) {
result.add(text[i]);
} else {
int ch = text.charCodeAt(i);
- if (ch >= 0xD800 && ch < 0xDC00) {
- // Low surrogate. We expect a next char high surrogate.
- ++i;
- int nextCh = text.length == i ? 0 : text.charCodeAt(i);
- if (nextCh >= 0xDC00 && nextCh < 0xE000) {
- // convert the pair to a U+10000 codepoint
- ch = 0x10000 + ((ch-0xD800) << 10) + (nextCh - 0xDC00);
- } else {
- throw new ArgumentError('Malformed URI');
- }
- }
+ if (ch >= 0x10000) i++;
for (int codepoint in codepointsToUtf8([ch])) {
result.add(byteToHex(codepoint));
}

Powered by Google App Engine
This is Rietveld 408576698