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

Unified Diff: runtime/bin/process.cc

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
« no previous file with comments | « runtime/bin/io_natives.cc ('k') | runtime/bin/process_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process.cc
diff --git a/runtime/bin/process.cc b/runtime/bin/process.cc
index b786ddb0e37ffb73753ecf19296e8b02dd1bf6af..e513939d4405a27075ee57726748793e28d78782 100644
--- a/runtime/bin/process.cc
+++ b/runtime/bin/process.cc
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
#include "bin/dartutils.h"
+#include "bin/io_buffer.h"
#include "bin/process.h"
#include "bin/socket.h"
@@ -177,3 +178,39 @@ Dart_Handle Process::SetProcessIdNativeField(Dart_Handle process,
intptr_t pid) {
return Dart_SetNativeInstanceField(process, kProcessIdNativeField, pid);
}
+
+
+void FUNCTION_NAME(SystemEncodingToString)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ Dart_Handle bytes = Dart_GetNativeArgument(args, 0);
+ intptr_t bytes_length = 0;
+ Dart_Handle result = Dart_ListLength(bytes, &bytes_length);
+ if (Dart_IsError(result)) Dart_PropagateError(result);
+ uint8_t* buffer = new uint8_t[bytes_length + 1];
Mads Ager (google) 2012/12/07 20:14:17 This and the '\0' assignment below are the only ch
+ result = Dart_ListGetAsBytes(bytes, 0, buffer, bytes_length);
+ buffer[bytes_length] = '\0';
+ if (Dart_IsError(result)) {
+ delete[] buffer;
+ Dart_PropagateError(result);
+ }
+ char* str =
+ StringUtils::SystemStringToUtf8(reinterpret_cast<char*>(buffer));
+ Dart_SetReturnValue(args, DartUtils::NewString(str));
+ if (str != reinterpret_cast<char*>(buffer)) free(str);
+ Dart_ExitScope();
+}
+
+
+void FUNCTION_NAME(StringToSystemEncoding)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ Dart_Handle str = Dart_GetNativeArgument(args, 0);
+ const char* utf8 = DartUtils::GetStringValue(str);
+ const char* system_string = StringUtils::Utf8ToSystemString(utf8);
+ int external_length = strlen(system_string);
+ uint8_t* buffer = NULL;
+ Dart_Handle external_array = IOBuffer::Allocate(external_length, &buffer);
+ memmove(buffer, system_string, external_length);
+ if (utf8 != system_string) free(const_cast<char*>(system_string));
+ Dart_SetReturnValue(args, external_array);
+ Dart_ExitScope();
+}
« no previous file with comments | « runtime/bin/io_natives.cc ('k') | runtime/bin/process_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698