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

Issue 11275281: Update dart:io to convert strings between UTF8 and current code page (Closed)

Created:
8 years, 1 month ago by Mads Ager (google)
Modified:
8 years, 1 month ago
Reviewers:
Søren Gjesse
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Update dart:io to convert strings between UTF8 and current code page when interacting with the system. What we get from and need to hand to the VM is utf8. What we get from and need to hand to the system is in the current code page. R=sgjesse@google.com BUG= Committed: https://code.google.com/p/dart/source/detail?r=14851

Patch Set 1 #

Total comments: 13

Patch Set 2 : Address comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+622 lines, -271 lines) Patch
M runtime/bin/directory_win.cc View 1 6 chunks +62 lines, -21 lines 0 comments Download
M runtime/bin/file_win.cc View 1 7 chunks +43 lines, -14 lines 0 comments Download
M runtime/bin/main.cc View 1 4 chunks +29 lines, -2 lines 0 comments Download
M runtime/bin/platform.h View 1 chunk +4 lines, -3 lines 0 comments Download
M runtime/bin/platform.cc View 3 chunks +8 lines, -6 lines 0 comments Download
M runtime/bin/platform_android.cc View 1 chunk +5 lines, -0 lines 0 comments Download
M runtime/bin/platform_linux.cc View 1 chunk +5 lines, -0 lines 0 comments Download
M runtime/bin/platform_macos.cc View 1 chunk +5 lines, -0 lines 0 comments Download
M runtime/bin/platform_win.cc View 3 chunks +10 lines, -4 lines 0 comments Download
M runtime/bin/process_win.cc View 6 chunks +24 lines, -0 lines 0 comments Download
M runtime/bin/utils.h View 1 chunk +12 lines, -0 lines 0 comments Download
M runtime/bin/utils_android.cc View 1 chunk +16 lines, -0 lines 0 comments Download
M runtime/bin/utils_linux.cc View 1 chunk +16 lines, -0 lines 0 comments Download
M runtime/bin/utils_macos.cc View 1 chunk +16 lines, -0 lines 0 comments Download
M runtime/bin/utils_win.cc View 1 chunk +34 lines, -0 lines 0 comments Download
M tests/standalone/float_array_test.dart View 1 chunk +215 lines, -215 lines 0 comments Download
A tests/standalone/io/directory_non_ascii_sync_test.dart View 1 chunk +17 lines, -0 lines 0 comments Download
A tests/standalone/io/directory_non_ascii_test.dart View 1 chunk +27 lines, -0 lines 0 comments Download
A tests/standalone/io/file_non_ascii_sync_test.dart View 1 chunk +17 lines, -0 lines 0 comments Download
A tests/standalone/io/file_non_ascii_test.dart View 1 chunk +32 lines, -0 lines 0 comments Download
A tests/standalone/io/process_non_ascii_test.dart View 3 chunks +22 lines, -6 lines 0 comments Download
M tests/standalone/standalone.status View 1 chunk +3 lines, -0 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
Mads Ager (google)
The combination of "const char*" and "malloc/free" is annoying. This is the current local optimum. ...
8 years, 1 month ago (2012-11-13 12:03:20 UTC) #1
Mads Ager (google)
https://codereview.chromium.org/11275281/diff/1/tests/standalone/float_array_test.dart File tests/standalone/float_array_test.dart (left): https://codereview.chromium.org/11275281/diff/1/tests/standalone/float_array_test.dart#oldcode1 tests/standalone/float_array_test.dart:1: // Copyright (c) 2012, the Dart project authors. Please ...
8 years, 1 month ago (2012-11-13 12:04:15 UTC) #2
Søren Gjesse
lgtm https://codereview.chromium.org/11275281/diff/1/runtime/bin/directory_win.cc File runtime/bin/directory_win.cc (right): https://codereview.chromium.org/11275281/diff/1/runtime/bin/directory_win.cc#newcode56 runtime/bin/directory_win.cc:56: char* utf8_encoded_path = StringUtils::SystemStringToUtf8(path); Maybe remove "encoded" from ...
8 years, 1 month ago (2012-11-13 12:48:45 UTC) #3
Mads Ager (google)
8 years, 1 month ago (2012-11-13 14:50:17 UTC) #4
https://codereview.chromium.org/11275281/diff/1/runtime/bin/directory_win.cc
File runtime/bin/directory_win.cc (right):

https://codereview.chromium.org/11275281/diff/1/runtime/bin/directory_win.cc#...
runtime/bin/directory_win.cc:56: char* utf8_encoded_path =
StringUtils::SystemStringToUtf8(path);
On 2012/11/13 12:48:45, Søren Gjesse wrote:
> Maybe remove "encoded" from utf8_encoded_path to shorten the name.

Done for all of them.

https://codereview.chromium.org/11275281/diff/1/runtime/bin/directory_win.cc#...
runtime/bin/directory_win.cc:57: bool ok =
listing->HandleDirectory(utf8_encoded_path);
On 2012/11/13 12:48:45, Søren Gjesse wrote:
> Maybe add ASSERT(utf8_encoded_path != path).

I think I would rather go with your suggestion of not converting when getting
ascii. In that case I need to add a guarding test here.

https://codereview.chromium.org/11275281/diff/1/runtime/bin/main.cc
File runtime/bin/main.cc (right):

https://codereview.chromium.org/11275281/diff/1/runtime/bin/main.cc#newcode236
runtime/bin/main.cc:236: // encoded in the current code page and not UTF8.
On 2012/11/13 12:48:45, Søren Gjesse wrote:
> Document return value.

Done.

https://codereview.chromium.org/11275281/diff/1/runtime/bin/main.cc#newcode241
runtime/bin/main.cc:241: if (argv[i] != arg) result = true;
On 2012/11/13 12:48:45, Søren Gjesse wrote:
> Maybe change this to
> 
> if (argv == 0) {
>   result = argv[i] != arg;
> } else {
>   ASSERT(result == (argv[i] != arg));
> }

Done.

https://codereview.chromium.org/11275281/diff/1/runtime/bin/main.cc#newcode652
runtime/bin/main.cc:652: // On Windows, the argv strings are code page incoded
and not
On 2012/11/13 12:48:45, Søren Gjesse wrote:
> incoded -> encoded

Done.

https://codereview.chromium.org/11275281/diff/1/runtime/bin/utils_win.cc
File runtime/bin/utils_win.cc (right):

https://codereview.chromium.org/11275281/diff/1/runtime/bin/utils_win.cc#newc...
runtime/bin/utils_win.cc:54: len = WideCharToMultiByte(CP_UTF8, 0, unicode, -1,
NULL, 0, NULL, NULL);
On 2012/11/13 12:48:45, Søren Gjesse wrote:
> If the len here and the len above are then same then it must be an ASCII
string
> and you should be able to just return str. That of cause means that you will
> have to check whether to free or not every time this method is used.
> 
> Or maybe check for ASCII string up-front.

Yeah, I think I'll save that for a separate change. Using the standard trick of
taking four bytes at a time and masking off an iteration up front for the common
ascii case is probably the cheapest.

Powered by Google App Engine
This is Rietveld 408576698