OLD | NEW |
---|---|
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 /** | 5 /** |
6 * Converters for JSON and UTF-8, as well as support for creating additional | 6 * Converters for JSON and UTF-8, as well as support for creating additional |
Søren Gjesse
2013/12/19 09:44:40
I think the first line should be updated to someth
mem
2013/12/19 23:24:24
Your comment drifted off....
Anyway, the conventi
| |
7 * converters. | 7 * converters. |
8 * | |
9 * The dart:convert library works in both web apps and command-line apps. | |
Lasse Reichstein Nielsen
2013/12/19 15:22:49
Wrap dart:convert in backquotes (`dart:convert`) f
mem
2013/12/19 23:24:24
Done.
| |
10 * To use it: | |
11 * | |
12 * import 'dart:convert'; | |
13 * | |
14 * Two commonly used converters are the top-level instances of | |
15 * [JsonCodec] and [Utf8Codec], named JSON and UTF8, respectively. | |
Lasse Reichstein Nielsen
2013/12/19 15:22:49
Add empty line before "JSON" and before "UTF-8" be
mem
2013/12/19 23:24:24
Done.
| |
16 * JSON is a simple text format for representing | |
Søren Gjesse
2013/12/19 09:44:40
I think we should be a bit more precise about the
Lasse Reichstein Nielsen
2013/12/19 15:22:49
Agree.
mem
2013/12/19 23:24:24
Done.
| |
17 * structured objects and collections. | |
18 * UTF-8 is a common variable-width encoding that can represent | |
19 * every character in the Unicode character set. | |
20 * | |
21 * Converters are often used with streams | |
22 * to transform the data that comes through the stream | |
23 * as it becomes available. | |
24 * The following code uses two converters. | |
25 * The first is a UTF8 decoder, which converts the data from bytes to UTF-8 | |
26 * as it's read from a file, | |
27 * The second is an instance of [LineSplitter], | |
28 * which splits the data on newline boundaries. | |
29 * | |
30 * int lineNumber = 1; | |
31 * Stream<List<int>> stream = new File('quotes.txt').openRead(); | |
32 * | |
33 * stream.transform(UTF8.decoder) | |
34 * .transform(const LineSplitter()) | |
35 * .listen((line) { | |
36 * if (showLineNumbers) { | |
37 * stdout.write('${lineNumber++} '); | |
38 * } | |
39 * stdout.writeln(line); | |
40 * }); | |
41 * | |
42 * See the documentation for the [Codec] and [Converter] classes | |
43 * for information about creating your own converters. | |
8 */ | 44 */ |
9 library dart.convert; | 45 library dart.convert; |
10 | 46 |
11 import 'dart:async'; | 47 import 'dart:async'; |
12 import "dart:collection" show HashSet; | 48 import "dart:collection" show HashSet; |
13 | 49 |
14 part 'ascii.dart'; | 50 part 'ascii.dart'; |
15 part 'byte_conversion.dart'; | 51 part 'byte_conversion.dart'; |
16 part 'chunked_conversion.dart'; | 52 part 'chunked_conversion.dart'; |
17 part 'codec.dart'; | 53 part 'codec.dart'; |
18 part 'converter.dart'; | 54 part 'converter.dart'; |
19 part 'encoding.dart'; | 55 part 'encoding.dart'; |
20 part 'html_escape.dart'; | 56 part 'html_escape.dart'; |
21 part 'json.dart'; | 57 part 'json.dart'; |
22 part 'latin1.dart'; | 58 part 'latin1.dart'; |
23 part 'line_splitter.dart'; | 59 part 'line_splitter.dart'; |
24 part 'string_conversion.dart'; | 60 part 'string_conversion.dart'; |
25 part 'utf.dart'; | 61 part 'utf.dart'; |
OLD | NEW |