This reverts commit df578330b8a0b1a003a37ca34253e7344caf17f4. Reason for revert: Still results in link errors for chromium on mac. Original change's description: > Reland "Delete mac_utils.h and mac_utils.cc" > > This is a reland of ada8e17125d2124f5bcdc1558182ce95d6311d93 > > Chromium link error should be fixed with > https://chromium-review.googlesource.com/c/chromium/src/+/1762071 > > Original change's description: > > Delete mac_utils.h and mac_utils.cc > > > > They defined two functions: ToUtf16 and ToUtf8. The former was unused, > > and the latter is moved to > > modules/desktop_capture/mac/window_list_utils.cc, the only user. > > > > Tbr: sergeyu@chromium.org > > Bug: None > > Change-Id: Ib8a513da42e43ba8d41a2de4c1645b3f48448dc9 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/148531 > > Commit-Queue: Niels Moller <nisse@webrtc.org> > > Reviewed-by: Kári Helgason <kthelgason@webrtc.org> > > Reviewed-by: Sergey Ulanov <sergeyu@google.com> > > Cr-Commit-Position: refs/heads/master@{#28913} > > Tbr: kthelgason@webrtc.org > Bug: None > Change-Id: If6d186d565c73e36ddb81b3ff05f6de6c9201326 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/149831 > Reviewed-by: Niels Moller <nisse@webrtc.org> > Commit-Queue: Niels Moller <nisse@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#28934} TBR=zijiehe@chromium.org,nisse@webrtc.org,kthelgason@webrtc.org,sergeyu@chromium.org Change-Id: I295cd23e63e17186f4c3c857ac0242467b7a68bf No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: None Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150107 Reviewed-by: Niels Moller <nisse@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28937}
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
/*
|
|
* Copyright 2007 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.
|
|
*/
|
|
|
|
#include "rtc_base/mac_utils.h"
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#include <cstring>
|
|
#include <memory>
|
|
|
|
#include "rtc_base/checks.h"
|
|
#include "rtc_base/logging.h"
|
|
|
|
namespace rtc {
|
|
|
|
bool ToUtf8(const CFStringRef str16, std::string* str8) {
|
|
if ((nullptr == str16) || (nullptr == str8)) {
|
|
return false;
|
|
}
|
|
size_t maxlen = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str16),
|
|
kCFStringEncodingUTF8) +
|
|
1;
|
|
std::unique_ptr<char[]> buffer(new char[maxlen]);
|
|
if (!buffer ||
|
|
!CFStringGetCString(str16, buffer.get(), maxlen, kCFStringEncodingUTF8)) {
|
|
return false;
|
|
}
|
|
str8->assign(buffer.get());
|
|
return true;
|
|
}
|
|
|
|
bool ToUtf16(const std::string& str8, CFStringRef* str16) {
|
|
if (nullptr == str16) {
|
|
return false;
|
|
}
|
|
*str16 = CFStringCreateWithBytes(kCFAllocatorDefault,
|
|
reinterpret_cast<const UInt8*>(str8.data()),
|
|
str8.length(), kCFStringEncodingUTF8, false);
|
|
return nullptr != *str16;
|
|
}
|
|
} // namespace rtc
|