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

Side by Side Diff: runtime/bin/utils_win.h

Issue 2698813002: [dart:io][windows] Make unicode characters display correctly. (Closed)
Patch Set: Address comments Created 3 years, 10 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
« no previous file with comments | « runtime/bin/run_vm_tests.cc ('k') | sdk/lib/io/file_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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #ifndef RUNTIME_BIN_UTILS_WIN_H_ 5 #ifndef RUNTIME_BIN_UTILS_WIN_H_
6 #define RUNTIME_BIN_UTILS_WIN_H_ 6 #define RUNTIME_BIN_UTILS_WIN_H_
7 7
8 #include "platform/globals.h" 8 #include "platform/globals.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 class Utf8ToWideScope { 70 class Utf8ToWideScope {
71 public: 71 public:
72 explicit Utf8ToWideScope(const char* utf8) { 72 explicit Utf8ToWideScope(const char* utf8) {
73 int wide_len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0); 73 int wide_len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0);
74 wchar_t* wide = new wchar_t[wide_len]; 74 wchar_t* wide = new wchar_t[wide_len];
75 MultiByteToWideChar(CP_UTF8, 0, utf8, -1, wide, wide_len); 75 MultiByteToWideChar(CP_UTF8, 0, utf8, -1, wide, wide_len);
76 length_ = wide_len; 76 length_ = wide_len;
77 wide_ = wide; 77 wide_ = wide;
78 } 78 }
79 79
80 Utf8ToWideScope(const char* utf8, intptr_t length) {
81 int wide_len = MultiByteToWideChar(CP_UTF8, 0, utf8, length, NULL, 0);
82 wchar_t* wide = new wchar_t[wide_len];
83 MultiByteToWideChar(CP_UTF8, 0, utf8, length, wide, wide_len);
84 length_ = wide_len;
85 wide_ = wide;
86 }
87
80 ~Utf8ToWideScope() { delete[] wide_; } 88 ~Utf8ToWideScope() { delete[] wide_; }
81 89
82 wchar_t* wide() const { return wide_; } 90 wchar_t* wide() const { return wide_; }
83 intptr_t length() const { return length_; } 91 intptr_t length() const { return length_; }
92 intptr_t size_in_bytes() const { return length_ * sizeof(*wide_); }
84 93
85 private: 94 private:
86 intptr_t length_; 95 intptr_t length_;
87 wchar_t* wide_; 96 wchar_t* wide_;
88 97
89 DISALLOW_ALLOCATION(); 98 DISALLOW_ALLOCATION();
90 DISALLOW_IMPLICIT_CONSTRUCTORS(Utf8ToWideScope); 99 DISALLOW_IMPLICIT_CONSTRUCTORS(Utf8ToWideScope);
91 }; 100 };
92 101
93 } // namespace bin 102 } // namespace bin
94 } // namespace dart 103 } // namespace dart
95 104
96 #endif // RUNTIME_BIN_UTILS_WIN_H_ 105 #endif // RUNTIME_BIN_UTILS_WIN_H_
OLDNEW
« no previous file with comments | « runtime/bin/run_vm_tests.cc ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698