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

Unified Diff: sdk/lib/io/string_stream.dart

Issue 11472032: Reapply change to use system code page on Windows to fix Pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 side-by-side diff with in-line comments
Download patch
« runtime/bin/process.cc ('K') | « sdk/lib/io/process.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/string_stream.dart
diff --git a/sdk/lib/io/string_stream.dart b/sdk/lib/io/string_stream.dart
index 49302c16172b2b3d02648221a4dadc74555aa3e6..4c73d15712fab2c3845fb52a48a8e30508e78d46 100644
--- a/sdk/lib/io/string_stream.dart
+++ b/sdk/lib/io/string_stream.dart
@@ -44,6 +44,11 @@ class _StringDecoders {
return new _Latin1Decoder();
} else if (encoding == Encoding.ASCII) {
return new _AsciiDecoder();
+ } else if (encoding == Encoding.SYSTEM) {
+ if (Platform.operatingSystem == 'windows') {
+ return new _WindowsCodePageDecoder();
+ }
+ return new _UTF8Decoder();
} else {
if (encoding is Encoding) {
throw new StreamException("Unsupported encoding ${encoding.name}");
@@ -250,6 +255,22 @@ class _Latin1Decoder extends _StringDecoderBase {
}
+// Utility class for decoding Windows current code page data delivered
+// as a stream of bytes.
+class _WindowsCodePageDecoder extends _StringDecoderBase {
+ // Process the next chunk of data.
+ bool _processNext() {
+ List<int> bytes = _bufferList.readBytes(_bufferList.length);
+ for (var charCode in _decodeBytes(bytes).charCodes) {
+ addChar(charCode);
+ }
+ return true;
+ }
+
+ external static String _decodeBytes(List<int> bytes);
+}
+
+
// Interface for encoders encoding string data into binary data.
abstract class _StringEncoder {
List<int> encodeString(String string);
@@ -313,6 +334,17 @@ class _AsciiEncoder implements _StringEncoder {
}
+// Utility class for encoding a string into a current windows
+// code page byte list.
+class _WindowsCodePageEncoder implements _StringEncoder {
+ List<int> encodeString(String string) {
+ return _encodeString(string);
+ }
+
+ external static List<int> _encodeString(String string);
+}
+
+
class _StringEncoders {
static _StringEncoder encoder(Encoding encoding) {
if (encoding == Encoding.UTF_8) {
@@ -321,6 +353,11 @@ class _StringEncoders {
return new _Latin1Encoder();
} else if (encoding == Encoding.ASCII) {
return new _AsciiEncoder();
+ } else if (encoding == Encoding.SYSTEM) {
+ if (Platform.operatingSystem == 'windows') {
+ return new _WindowsCodePageEncoder();
+ }
+ return new _UTF8Encoder();
} else {
throw new StreamException("Unsupported encoding ${encoding.name}");
}
« runtime/bin/process.cc ('K') | « sdk/lib/io/process.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698