OLD | NEW |
1 part of dart.convert; | 1 part of dart.convert; |
2 const AsciiCodec ASCII = const AsciiCodec(); | 2 const AsciiCodec ASCII = const AsciiCodec(); |
3 const int _ASCII_MASK = 0x7F; | 3 const int _ASCII_MASK = 0x7F; |
4 class AsciiCodec extends Encoding {final bool _allowInvalid; | 4 class AsciiCodec extends Encoding {final bool _allowInvalid; |
5 const AsciiCodec({ | 5 const AsciiCodec({ |
6 bool allowInvalid : false} | 6 bool allowInvalid : false} |
7 ) : _allowInvalid = allowInvalid; | 7 ) : _allowInvalid = allowInvalid; |
8 String get name => "us-ascii"; | 8 String get name => "us-ascii"; |
9 String decode(List<int> bytes, { | 9 String decode(List<int> bytes, { |
10 bool allowInvalid} | 10 bool allowInvalid} |
(...skipping 17 matching lines...) Expand all Loading... |
28 if (end == null) end = stringLength; | 28 if (end == null) end = stringLength; |
29 int length = end - start; | 29 int length = end - start; |
30 List result = new Uint8List(length); | 30 List result = new Uint8List(length); |
31 for (int i = 0; i < length; i++) { | 31 for (int i = 0; i < length; i++) { |
32 var codeUnit = string.codeUnitAt(start + i); | 32 var codeUnit = string.codeUnitAt(start + i); |
33 if ((codeUnit & ~_subsetMask) != 0) { | 33 if ((codeUnit & ~_subsetMask) != 0) { |
34 throw new ArgumentError("String contains invalid characters."); | 34 throw new ArgumentError("String contains invalid characters."); |
35 } | 35 } |
36 result[i] = codeUnit; | 36 result[i] = codeUnit; |
37 } | 37 } |
38 return DDC$RT.cast(result, DDC$RT.type((List<dynamic> _) { | 38 return DEVC$RT.cast(result, DEVC$RT.type((List<dynamic> _) { |
39 } | 39 } |
40 ), DDC$RT.type((List<int> _) { | 40 ), DEVC$RT.type((List<int> _) { |
41 } | 41 } |
42 ), "CastDynamic", """line 96, column 12 of dart:convert/ascii.dart: """, result
is List<int>, false); | 42 ), "CastDynamic", """line 96, column 12 of dart:convert/ascii.dart: """, result
is List<int>, false); |
43 } | 43 } |
44 StringConversionSink startChunkedConversion(Sink<List<int>> sink) { | 44 StringConversionSink startChunkedConversion(Sink<List<int>> sink) { |
45 if (sink is! ByteConversionSink) { | 45 if (sink is! ByteConversionSink) { |
46 sink = new ByteConversionSink.from(sink); | 46 sink = new ByteConversionSink.from(sink); |
47 } | 47 } |
48 return new _UnicodeSubsetEncoderSink(_subsetMask, DDC$RT.cast(sink, DDC$RT.type
((Sink<List<int>> _) { | 48 return new _UnicodeSubsetEncoderSink(_subsetMask, DEVC$RT.cast(sink, DEVC$RT.ty
pe((Sink<List<int>> _) { |
49 } | 49 } |
50 ), ByteConversionSink, "CastGeneral", """line 109, column 55 of dart:convert/asc
ii.dart: """, sink is ByteConversionSink, true)); | 50 ), ByteConversionSink, "CastGeneral", """line 109, column 55 of dart:convert/asc
ii.dart: """, sink is ByteConversionSink, true)); |
51 } | 51 } |
52 Stream<List<int>> bind(Stream<String> stream) => ((__x0) => DDC$RT.cast(__x0, D
DC$RT.type((DDC$async$.Stream<dynamic> _) { | 52 Stream<List<int>> bind(Stream<String> stream) => ((__x0) => DEVC$RT.cast(__x0,
DEVC$RT.type((DDC$async$.Stream<dynamic> _) { |
53 } | 53 } |
54 ), DDC$RT.type((DDC$async$.Stream<List<int>> _) { | 54 ), DEVC$RT.type((DDC$async$.Stream<List<int>> _) { |
55 } | 55 } |
56 ), "CastDynamic", """line 113, column 52 of dart:convert/ascii.dart: """, __x0 i
s DDC$async$.Stream<List<int>>, false))(super.bind(stream)); | 56 ), "CastDynamic", """line 113, column 52 of dart:convert/ascii.dart: """, __x0 i
s DDC$async$.Stream<List<int>>, false))(super.bind(stream)); |
57 } | 57 } |
58 class AsciiEncoder extends _UnicodeSubsetEncoder {const AsciiEncoder() : super(
_ASCII_MASK); | 58 class AsciiEncoder extends _UnicodeSubsetEncoder {const AsciiEncoder() : super(
_ASCII_MASK); |
59 } | 59 } |
60 class _UnicodeSubsetEncoderSink extends StringConversionSinkBase {final ByteCon
versionSink _sink; | 60 class _UnicodeSubsetEncoderSink extends StringConversionSinkBase {final ByteCon
versionSink _sink; |
61 final int _subsetMask; | 61 final int _subsetMask; |
62 _UnicodeSubsetEncoderSink(this._subsetMask, this._sink); | 62 _UnicodeSubsetEncoderSink(this._subsetMask, this._sink); |
63 void close() { | 63 void close() { |
64 _sink.close(); | 64 _sink.close(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 String _convertInvalid(List<int> bytes, int start, int end) { | 99 String _convertInvalid(List<int> bytes, int start, int end) { |
100 StringBuffer buffer = new StringBuffer(); | 100 StringBuffer buffer = new StringBuffer(); |
101 for (int i = start; i < end; i++) { | 101 for (int i = start; i < end; i++) { |
102 int value = bytes[i]; | 102 int value = bytes[i]; |
103 if ((value & ~_subsetMask) != 0) value = 0xFFFD; | 103 if ((value & ~_subsetMask) != 0) value = 0xFFFD; |
104 buffer.writeCharCode(value); | 104 buffer.writeCharCode(value); |
105 } | 105 } |
106 return buffer.toString(); | 106 return buffer.toString(); |
107 } | 107 } |
108 ByteConversionSink startChunkedConversion(Sink<String> sink); | 108 ByteConversionSink startChunkedConversion(Sink<String> sink); |
109 Stream<String> bind(Stream<List<int>> stream) => ((__x1) => DDC$RT.cast(__x1, D
DC$RT.type((DDC$async$.Stream<dynamic> _) { | 109 Stream<String> bind(Stream<List<int>> stream) => ((__x1) => DEVC$RT.cast(__x1,
DEVC$RT.type((DDC$async$.Stream<dynamic> _) { |
110 } | 110 } |
111 ), DDC$RT.type((DDC$async$.Stream<String> _) { | 111 ), DEVC$RT.type((DDC$async$.Stream<String> _) { |
112 } | 112 } |
113 ), "CastDynamic", """line 221, column 52 of dart:convert/ascii.dart: """, __x1 i
s DDC$async$.Stream<String>, false))(super.bind(stream)); | 113 ), "CastDynamic", """line 221, column 52 of dart:convert/ascii.dart: """, __x1 i
s DDC$async$.Stream<String>, false))(super.bind(stream)); |
114 } | 114 } |
115 class AsciiDecoder extends _UnicodeSubsetDecoder {const AsciiDecoder({ | 115 class AsciiDecoder extends _UnicodeSubsetDecoder {const AsciiDecoder({ |
116 bool allowInvalid : false} | 116 bool allowInvalid : false} |
117 ) : super(allowInvalid, _ASCII_MASK); | 117 ) : super(allowInvalid, _ASCII_MASK); |
118 ByteConversionSink startChunkedConversion(Sink<String> sink) { | 118 ByteConversionSink startChunkedConversion(Sink<String> sink) { |
119 StringConversionSink stringSink; | 119 StringConversionSink stringSink; |
120 if (sink is StringConversionSink) { | 120 if (sink is StringConversionSink) { |
121 stringSink = sink; | 121 stringSink = sink; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 RangeError.checkValidRange(start, end, length); | 174 RangeError.checkValidRange(start, end, length); |
175 if (start < end) { | 175 if (start < end) { |
176 if (start != 0 || end != length) { | 176 if (start != 0 || end != length) { |
177 source = source.sublist(start, end); | 177 source = source.sublist(start, end); |
178 } | 178 } |
179 add(source); | 179 add(source); |
180 } | 180 } |
181 if (isLast) close(); | 181 if (isLast) close(); |
182 } | 182 } |
183 } | 183 } |
OLD | NEW |