| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2007 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <memory> |
| 11 #include <sstream> | 12 #include <sstream> |
| 12 | 13 |
| 13 #include "webrtc/base/common.h" | 14 #include "webrtc/base/common.h" |
| 14 #include "webrtc/base/logging.h" | 15 #include "webrtc/base/logging.h" |
| 15 #include "webrtc/base/macutils.h" | 16 #include "webrtc/base/macutils.h" |
| 16 #include "webrtc/base/scoped_ptr.h" | |
| 17 #include "webrtc/base/stringutils.h" | 17 #include "webrtc/base/stringutils.h" |
| 18 | 18 |
| 19 namespace rtc { | 19 namespace rtc { |
| 20 | 20 |
| 21 /////////////////////////////////////////////////////////////////////////////// | 21 /////////////////////////////////////////////////////////////////////////////// |
| 22 | 22 |
| 23 bool ToUtf8(const CFStringRef str16, std::string* str8) { | 23 bool ToUtf8(const CFStringRef str16, std::string* str8) { |
| 24 if ((NULL == str16) || (NULL == str8)) { | 24 if ((NULL == str16) || (NULL == str8)) { |
| 25 return false; | 25 return false; |
| 26 } | 26 } |
| 27 size_t maxlen = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str16), | 27 size_t maxlen = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str16), |
| 28 kCFStringEncodingUTF8) + 1; | 28 kCFStringEncodingUTF8) + 1; |
| 29 scoped_ptr<char[]> buffer(new char[maxlen]); | 29 std::unique_ptr<char[]> buffer(new char[maxlen]); |
| 30 if (!buffer || !CFStringGetCString(str16, buffer.get(), maxlen, | 30 if (!buffer || !CFStringGetCString(str16, buffer.get(), maxlen, |
| 31 kCFStringEncodingUTF8)) { | 31 kCFStringEncodingUTF8)) { |
| 32 return false; | 32 return false; |
| 33 } | 33 } |
| 34 str8->assign(buffer.get()); | 34 str8->assign(buffer.get()); |
| 35 return true; | 35 return true; |
| 36 } | 36 } |
| 37 | 37 |
| 38 bool ToUtf16(const std::string& str8, CFStringRef* str16) { | 38 bool ToUtf16(const std::string& str8, CFStringRef* str16) { |
| 39 if (NULL == str16) { | 39 if (NULL == str16) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 #else | 212 #else |
| 213 // TODO(thaloun): Support applescripts with the NSAppleScript API. | 213 // TODO(thaloun): Support applescripts with the NSAppleScript API. |
| 214 return false; | 214 return false; |
| 215 #endif // CARBON_DEPRECATED | 215 #endif // CARBON_DEPRECATED |
| 216 } | 216 } |
| 217 #endif // WEBRTC_MAC && !defined(WEBRTC_IOS) | 217 #endif // WEBRTC_MAC && !defined(WEBRTC_IOS) |
| 218 | 218 |
| 219 /////////////////////////////////////////////////////////////////////////////// | 219 /////////////////////////////////////////////////////////////////////////////// |
| 220 | 220 |
| 221 } // namespace rtc | 221 } // namespace rtc |
| OLD | NEW |