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

Side by Side Diff: sdk/lib/convert/latin1.dart

Issue 1827803002: Make convert library strong-mode compliant. Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix more converters. Created 4 years, 9 months 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 unified diff | Download patch
« no previous file with comments | « sdk/lib/convert/json.dart ('k') | sdk/lib/convert/line_splitter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.convert; 5 part of dart.convert;
6 6
7 /** 7 /**
8 * An instance of the default implementation of the [Latin1Codec]. 8 * An instance of the default implementation of the [Latin1Codec].
9 * 9 *
10 * This instance provides a convenient access to the most common ISO Latin 1 10 * This instance provides a convenient access to the most common ISO Latin 1
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 */ 52 */
53 String decode(List<int> bytes, { bool allowInvalid }) { 53 String decode(List<int> bytes, { bool allowInvalid }) {
54 if (allowInvalid == null) allowInvalid = _allowInvalid; 54 if (allowInvalid == null) allowInvalid = _allowInvalid;
55 if (allowInvalid) { 55 if (allowInvalid) {
56 return const Latin1Decoder(allowInvalid: true).convert(bytes); 56 return const Latin1Decoder(allowInvalid: true).convert(bytes);
57 } else { 57 } else {
58 return const Latin1Decoder(allowInvalid: false).convert(bytes); 58 return const Latin1Decoder(allowInvalid: false).convert(bytes);
59 } 59 }
60 } 60 }
61 61
62 Converter<String, List<int>> get encoder => const Latin1Encoder(); 62 Latin1Encoder get encoder => const Latin1Encoder();
63 63
64 Converter<List<int>, String> get decoder => 64 Latin1Decoder get decoder =>
65 _allowInvalid ? const Latin1Decoder(allowInvalid: true) 65 _allowInvalid ? const Latin1Decoder(allowInvalid: true)
66 : const Latin1Decoder(allowInvalid: false); 66 : const Latin1Decoder(allowInvalid: false);
67 } 67 }
68 68
69 /** 69 /**
70 * This class converts strings of only ISO Latin-1 characters to bytes. 70 * This class converts strings of only ISO Latin-1 characters to bytes.
71 */ 71 */
72 class Latin1Encoder extends _UnicodeSubsetEncoder { 72 class Latin1Encoder extends _UnicodeSubsetEncoder {
73 const Latin1Encoder() : super(_LATIN1_MASK); 73 const Latin1Encoder() : super(_LATIN1_MASK);
74 } 74 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 185 }
186 } 186 }
187 if (start < end) { 187 if (start < end) {
188 _addSliceToSink(source, start, end, isLast); 188 _addSliceToSink(source, start, end, isLast);
189 } 189 }
190 if (isLast) { 190 if (isLast) {
191 close(); 191 close();
192 } 192 }
193 } 193 }
194 } 194 }
OLDNEW
« no previous file with comments | « sdk/lib/convert/json.dart ('k') | sdk/lib/convert/line_splitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698