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

Side by Side Diff: sdk/lib/io/string_transformer.dart

Issue 12504006: Make IOSink implement StringSink (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed second round of review comments Created 7 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/io_sink.dart ('k') | sdk/lib/io/websocket_impl.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.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * String encodings. 8 * String encodings.
9 */ 9 */
10 class Encoding { 10 class Encoding {
11 static const Encoding UTF_8 = const Encoding._internal("utf-8"); 11 static const Encoding UTF_8 = const Encoding._internal("utf-8");
12 static const Encoding ISO_8859_1 = const Encoding._internal("iso-8859-1"); 12 static const Encoding ISO_8859_1 = const Encoding._internal("iso-8859-1");
13 static const Encoding ASCII = const Encoding._internal("us-ascii"); 13 static const Encoding ASCII = const Encoding._internal("us-ascii");
14 14
15 // All aliasses (in lowercase) of supported encoding from
16 // http://www.iana.org/assignments/character-sets/character-sets.xml.
17 static Map<String, Encoding> _nameToEncoding = <String, Encoding> {
18 // ISO_8859-1:1987.
19 "iso_8859-1:1987": ISO_8859_1,
20 "iso-ir-100": ISO_8859_1,
21 "iso_8859-1": ISO_8859_1,
22 "iso-8859-1": ISO_8859_1,
23 "latin1": ISO_8859_1,
24 "l1": ISO_8859_1,
25 "ibm819": ISO_8859_1,
26 "cp819": ISO_8859_1,
27 "csisolatin1": ISO_8859_1,
28
29 // US-ASCII.
30 "iso-ir-6": ASCII,
31 "ansi_x3.4-1968": ASCII,
32 "ansi_x3.4-1986": ASCII,
33 "iso_646.irv:1991": ASCII,
34 "iso646-us": ASCII,
35 "us-ascii": ASCII,
36 "us": ASCII,
37 "ibm367": ASCII,
38 "cp367": ASCII,
39 "csascii": ASCII,
40 "ascii": ASCII, // This is not in the IANA official names.
41
42 // UTF-8.
43 "csutf8": UTF_8,
44 "utf-8": UTF_8
45 };
46
47 /**
48 * Gets an [Encoding] object from the name of the character set
49 * name. The names used are the IANA official names for the
50 * character set (see
51 * http://www.iana.org/assignments/character-sets/character-sets.xml).
52 *
53 * The [name] passed is case insensitive.
54 *
55 * If character set is not supported [:null:] is returned.
56 */
57 static Encoding fromName(String name) {
58 if (name == null) return null;
59 name = name.toLowerCase();
60 return _nameToEncoding[name];
61 }
62
15 /** 63 /**
16 * Name of the encoding. This will be the lower-case version of one of the 64 * Name of the encoding. This will be the lower-case version of one of the
17 * IANA official names for the character set (see 65 * IANA official names for the character set (see
18 * http://www.iana.org/assignments/character-sets/character-sets.xml) 66 * http://www.iana.org/assignments/character-sets/character-sets.xml)
19 */ 67 */
20 final String name; 68 final String name;
21 69
22 /** 70 /**
23 * SYSTEM encoding is the current code page on Windows and UTF-8 on 71 * SYSTEM encoding is the current code page on Windows and UTF-8 on
24 * Linux and Mac. 72 * Linux and Mac.
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 361
314 // Utility class for decoding Windows current code page data delivered 362 // Utility class for decoding Windows current code page data delivered
315 // as a stream of bytes. 363 // as a stream of bytes.
316 class _WindowsCodePageDecoder extends StreamEventTransformer<List<int>, String> { 364 class _WindowsCodePageDecoder extends StreamEventTransformer<List<int>, String> {
317 void handleData(List<int> data, StreamSink<String> sink) { 365 void handleData(List<int> data, StreamSink<String> sink) {
318 sink.add(_decodeBytes(data)); 366 sink.add(_decodeBytes(data));
319 } 367 }
320 368
321 external static String _decodeBytes(List<int> bytes); 369 external static String _decodeBytes(List<int> bytes);
322 } 370 }
OLDNEW
« no previous file with comments | « sdk/lib/io/io_sink.dart ('k') | sdk/lib/io/websocket_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698