From 07b8388234624c31aad7a7f4f5be2ecb2ee76ff8 Mon Sep 17 00:00:00 2001 From: nisse Date: Tue, 14 Mar 2017 01:32:50 -0700 Subject: [PATCH] Delete utf_util_win.h. It duplicates base/win32.h. BUG=None Review-Url: https://codereview.webrtc.org/2744833002 Cr-Commit-Position: refs/heads/master@{#17221} --- webrtc/system_wrappers/BUILD.gn | 1 - webrtc/system_wrappers/include/utf_util_win.h | 58 ------------------- webrtc/test/testsupport/fileutils.cc | 8 +-- 3 files changed, 4 insertions(+), 63 deletions(-) delete mode 100644 webrtc/system_wrappers/include/utf_util_win.h diff --git a/webrtc/system_wrappers/BUILD.gn b/webrtc/system_wrappers/BUILD.gn index 96177fd508..83f5f23d1f 100644 --- a/webrtc/system_wrappers/BUILD.gn +++ b/webrtc/system_wrappers/BUILD.gn @@ -35,7 +35,6 @@ rtc_static_library("system_wrappers") { "include/stringize_macros.h", "include/timestamp_extrapolator.h", "include/trace.h", - "include/utf_util_win.h", "source/aligned_malloc.cc", "source/atomic32_win.cc", "source/clock.cc", diff --git a/webrtc/system_wrappers/include/utf_util_win.h b/webrtc/system_wrappers/include/utf_util_win.h deleted file mode 100644 index ac91fe30fe..0000000000 --- a/webrtc/system_wrappers/include/utf_util_win.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// Conversion functions for UTF-8 and UTF-16 strings on Windows. -// Duplicated from talk/base/win32.h. -#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_UTF_UTIL_H_ -#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_UTF_UTIL_H_ - -#ifdef WIN32 -#include - -#include -#include - - -namespace webrtc { - -inline std::wstring ToUtf16(const char* utf8, size_t len) { - int len16 = ::MultiByteToWideChar(CP_UTF8, 0, utf8, static_cast(len), - NULL, 0); - std::unique_ptr ws(new wchar_t[len16]); - ::MultiByteToWideChar(CP_UTF8, 0, utf8, static_cast(len), ws.get(), - len16); - return std::wstring(ws.get(), len16); -} - -inline std::wstring ToUtf16(const std::string& str) { - return ToUtf16(str.data(), str.length()); -} - -inline std::string ToUtf8(const wchar_t* wide, size_t len) { - int len8 = ::WideCharToMultiByte(CP_UTF8, 0, wide, static_cast(len), - NULL, 0, NULL, NULL); - std::unique_ptr ns(new char[len8]); - ::WideCharToMultiByte(CP_UTF8, 0, wide, static_cast(len), ns.get(), len8, - NULL, NULL); - return std::string(ns.get(), len8); -} - -inline std::string ToUtf8(const wchar_t* wide) { - return ToUtf8(wide, wcslen(wide)); -} - -inline std::string ToUtf8(const std::wstring& wstr) { - return ToUtf8(wstr.data(), wstr.length()); -} - -} // namespace webrtc - -#endif // WIN32 -#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_UTF_UTIL_H_ diff --git a/webrtc/test/testsupport/fileutils.cc b/webrtc/test/testsupport/fileutils.cc index 2d3ea00925..2555f5cc07 100644 --- a/webrtc/test/testsupport/fileutils.cc +++ b/webrtc/test/testsupport/fileutils.cc @@ -21,7 +21,7 @@ #include "Shlwapi.h" #include "WinDef.h" -#include "webrtc/system_wrappers/include/utf_util_win.h" +#include "webrtc/base/win32.h" #define GET_CURRENT_DIR _getcwd #else #include @@ -183,9 +183,9 @@ std::string WorkingDir() { std::string TempFilename(const std::string &dir, const std::string &prefix) { #ifdef WIN32 wchar_t filename[MAX_PATH]; - if (::GetTempFileName(ToUtf16(dir).c_str(), - ToUtf16(prefix).c_str(), 0, filename) != 0) - return ToUtf8(filename); + if (::GetTempFileName(rtc::ToUtf16(dir).c_str(), + rtc::ToUtf16(prefix).c_str(), 0, filename) != 0) + return rtc::ToUtf8(filename); assert(false); return ""; #else