Index: sdk/lib/convert/convert.dart |
diff --git a/sdk/lib/convert/convert.dart b/sdk/lib/convert/convert.dart |
index 8cdc936993aff2722594fe21a9f5b6c26782acff..a314353dee819a00f04310d854dcf64f99a13940 100644 |
--- a/sdk/lib/convert/convert.dart |
+++ b/sdk/lib/convert/convert.dart |
@@ -5,6 +5,42 @@ |
/** |
* 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
|
* converters. |
+ * |
+ * 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.
|
+ * To use it: |
+ * |
+ * import 'dart:convert'; |
+ * |
+ * Two commonly used converters are the top-level instances of |
+ * [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.
|
+ * 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.
|
+ * structured objects and collections. |
+ * UTF-8 is a common variable-width encoding that can represent |
+ * every character in the Unicode character set. |
+ * |
+ * Converters are often used with streams |
+ * to transform the data that comes through the stream |
+ * as it becomes available. |
+ * The following code uses two converters. |
+ * The first is a UTF8 decoder, which converts the data from bytes to UTF-8 |
+ * as it's read from a file, |
+ * The second is an instance of [LineSplitter], |
+ * which splits the data on newline boundaries. |
+ * |
+ * int lineNumber = 1; |
+ * Stream<List<int>> stream = new File('quotes.txt').openRead(); |
+ * |
+ * stream.transform(UTF8.decoder) |
+ * .transform(const LineSplitter()) |
+ * .listen((line) { |
+ * if (showLineNumbers) { |
+ * stdout.write('${lineNumber++} '); |
+ * } |
+ * stdout.writeln(line); |
+ * }); |
+ * |
+ * See the documentation for the [Codec] and [Converter] classes |
+ * for information about creating your own converters. |
*/ |
library dart.convert; |