Skip to content

Commit 3c0ac36

Browse files
committed
Remove deprecated string features.
Make String.codeUnits return a List. Review URL: https://codereview.chromium.org//12282038 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18960 260f80e4-7a28-3924-810f-c04153c831b5
1 parent 01b252d commit 3c0ac36

File tree

130 files changed

+640
-704
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+640
-704
lines changed

pkg/fixnum/lib/src/int32.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ class int32 implements intx {
3838
static int32 TWO = const int32._internal(2);
3939

4040
// Hex digit char codes
41-
static const int _CC_0 = 48; // '0'.charCodeAt(0)
42-
static const int _CC_9 = 57; // '9'.charCodeAt(0)
43-
static const int _CC_a = 97; // 'a'.charCodeAt(0)
44-
static const int _CC_z = 122; // 'z'.charCodeAt(0)
45-
static const int _CC_A = 65; // 'A'.charCodeAt(0)
46-
static const int _CC_Z = 90; // 'Z'.charCodeAt(0)
41+
static const int _CC_0 = 48; // '0'.codeUnitAt(0)
42+
static const int _CC_9 = 57; // '9'.codeUnitAt(0)
43+
static const int _CC_a = 97; // 'a'.codeUnitAt(0)
44+
static const int _CC_z = 122; // 'z'.codeUnitAt(0)
45+
static const int _CC_A = 65; // 'A'.codeUnitAt(0)
46+
static const int _CC_Z = 90; // 'Z'.codeUnitAt(0)
4747

4848
static int _decodeHex(int c) {
4949
if (c >= _CC_0 && c <= _CC_9) {
@@ -68,10 +68,10 @@ class int32 implements intx {
6868
}
6969
int32 x = ZERO;
7070
for (int i = 0; i < s.length; i++) {
71-
int c = s.charCodeAt(i);
71+
int c = s.codeUnitAt(i);
7272
int digit = _decodeHex(c);
7373
if (digit < 0 || digit >= radix) {
74-
throw new Exception("Non-radix char code: $c");
74+
throw new Exception("Non-radix code unit: $c");
7575
}
7676
x = (x * radix) + digit;
7777
}

pkg/fixnum/lib/src/int64.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class int64 implements intx {
130130
i++;
131131
}
132132
for (; i < s.length; i++) {
133-
int c = s.charCodeAt(i);
133+
int c = s.codeUnitAt(i);
134134
int digit = int32._decodeHex(c);
135135
if (digit < 0 || digit >= radix) {
136136
throw new Exception("Non-radix char code: $c");

pkg/http/lib/src/multipart_request.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class MultipartRequest extends BaseRequest {
9898

9999
void writeAscii(String string) {
100100
assert(isPlainAscii(string));
101-
controller.add(string.charCodes);
101+
controller.add(string.codeUnits);
102102
}
103103

104104
writeUtf8(String string) => controller.add(encodeUtf8(string));

pkg/http/lib/src/utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ String decodeString(List<int> bytes, Encoding encoding) {
111111
/// Converts [string] into a byte array according to [encoding].
112112
List<int> encodeString(String string, Encoding encoding) {
113113
// TODO(nweiz): implement this once issue 6284 is fixed.
114-
return string.charCodes;
114+
return string.codeUnits;
115115
}
116116

117117
/// A regular expression that matches strings that are composed entirely of

pkg/http/test/client_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void main() {
4141
'body': '{"hello": "world"}'
4242
}))));
4343

44-
request.sink.add('{"hello": "world"}'.charCodes);
44+
request.sink.add('{"hello": "world"}'.codeUnits);
4545
request.sink.close();
4646
}), completes);
4747
});
@@ -56,7 +56,7 @@ void main() {
5656

5757
expect(client.send(request), throwsSocketIOException);
5858

59-
request.sink.add('{"hello": "world"}'.charCodes);
59+
request.sink.add('{"hello": "world"}'.codeUnits);
6060
request.sink.close();
6161
}), completes);
6262
});

pkg/http/test/mock_client_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void main() {
3737
return bodyStream.bytesToString().then((bodyString) {
3838
var controller = new StreamController<List<int>>();
3939
async.then((_) {
40-
controller.add('Request body was "$bodyString"'.charCodes);
40+
controller.add('Request body was "$bodyString"'.codeUnits);
4141
controller.close();
4242
});
4343

pkg/intl/lib/number_format.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class NumberFormat {
169169
paddingDigits.add(symbols.ZERO_DIGIT);
170170
intValue = intValue ~/ 10;
171171
}
172-
var integerDigits = "${intValue}${paddingDigits}".charCodes;
172+
var integerDigits = "${intValue}${paddingDigits}".codeUnits;
173173
var digitLength = integerDigits.length;
174174

175175
if (_hasPrintableIntegerPart(intValue)) {
@@ -191,7 +191,7 @@ class NumberFormat {
191191
* Format the part after the decimal place in a fixed point number.
192192
*/
193193
void _formatFractionPart(String fractionPart) {
194-
var fractionCodes = fractionPart.charCodes;
194+
var fractionCodes = fractionPart.codeUnits;
195195
var fractionLength = fractionPart.length;
196196
while (fractionPart[fractionLength - 1] == '0' &&
197197
fractionLength > _minimumFractionDigits + 1) {
@@ -237,7 +237,7 @@ class NumberFormat {
237237
for (var i = 0; i < numberOfDigits - basic.length; i++) {
238238
_add(symbols.ZERO_DIGIT);
239239
}
240-
for (var x in basic.charCodes) {
240+
for (var x in basic.codeUnits) {
241241
_addDigit(x);
242242
}
243243
}

pkg/serialization/test/polyfill_identity_map_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ main() {
4040
test('uniquing primitives', () {
4141
var map = new IdentityMap();
4242
var one = 'one';
43-
var two = new String.fromCharCodes(one.charCodes);
43+
var two = new String.fromCharCodes(one.codeUnits);
4444
map[one] = 1;
4545
expect(map[two], 1);
4646
expect(map[one], 1);
4747
});
48-
}
48+
}

pkg/serialization/test/serialization_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ main() {
154154
var l = keysAndValues(list);
155155
var s = keysAndValues(set);
156156

157-
m.forEach((key, value) {expect(key.charCodes[0], value + 96);});
157+
m.forEach((key, value) {expect(key.codeUnits[0], value + 96);});
158158
l.forEach((key, value) {expect(key + 1, value);});
159159
var index = 0;
160160
var seen = new Set();

pkg/webdriver/lib/src/base64decoder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ part of webdriver;
1111
class Base64Decoder {
1212

1313
static int getVal(String s, pos) {
14-
int code = s.charCodeAt(pos);
14+
int code = s.codeUnitAt(pos);
1515
if (code >= 65 && code < (65+26)) { // 'A'..'Z'
1616
return code - 65;
1717
} else if (code >= 97 && code < (97+26)) { // 'a'..'z'

0 commit comments

Comments
 (0)