| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_SYS_STRING_CONVERSIONS_H_ | 5 #ifndef BASE_SYS_STRING_CONVERSIONS_H_ |
| 6 #define BASE_SYS_STRING_CONVERSIONS_H_ | 6 #define BASE_SYS_STRING_CONVERSIONS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 // Provides system-dependent string type conversions for cases where it's | 9 // Provides system-dependent string type conversions for cases where it's |
| 10 // necessary to not use ICU. Generally, you should not need this in Chrome, | 10 // necessary to not use ICU. Generally, you should not need this in Chrome, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 #endif // defined(OS_WIN) | 55 #endif // defined(OS_WIN) |
| 56 | 56 |
| 57 // Mac-specific ---------------------------------------------------------------- | 57 // Mac-specific ---------------------------------------------------------------- |
| 58 | 58 |
| 59 #if defined(OS_MACOSX) | 59 #if defined(OS_MACOSX) |
| 60 | 60 |
| 61 // Converts between STL strings and CFStringRefs/NSStrings. | 61 // Converts between STL strings and CFStringRefs/NSStrings. |
| 62 | 62 |
| 63 // Creates a string, and returns it with a refcount of 1. You are responsible | 63 // Creates a string, and returns it with a refcount of 1. You are responsible |
| 64 // for releasing it. Returns NULL on failure. | 64 // for releasing it. Returns NULL on failure. |
| 65 CFStringRef SysUTF8ToCFStringRef(const std::string& utf8); | 65 BASE_API CFStringRef SysUTF8ToCFStringRef(const std::string& utf8); |
| 66 CFStringRef SysUTF16ToCFStringRef(const string16& utf16); | 66 BASE_API CFStringRef SysUTF16ToCFStringRef(const string16& utf16); |
| 67 CFStringRef SysWideToCFStringRef(const std::wstring& wide); | 67 BASE_API CFStringRef SysWideToCFStringRef(const std::wstring& wide); |
| 68 | 68 |
| 69 // Same, but returns an autoreleased NSString. | 69 // Same, but returns an autoreleased NSString. |
| 70 NSString* SysUTF8ToNSString(const std::string& utf8); | 70 BASE_API NSString* SysUTF8ToNSString(const std::string& utf8); |
| 71 NSString* SysUTF16ToNSString(const string16& utf16); | 71 BASE_API NSString* SysUTF16ToNSString(const string16& utf16); |
| 72 NSString* SysWideToNSString(const std::wstring& wide); | 72 BASE_API NSString* SysWideToNSString(const std::wstring& wide); |
| 73 | 73 |
| 74 // Converts a CFStringRef to an STL string. Returns an empty string on failure. | 74 // Converts a CFStringRef to an STL string. Returns an empty string on failure. |
| 75 std::string SysCFStringRefToUTF8(CFStringRef ref); | 75 BASE_API std::string SysCFStringRefToUTF8(CFStringRef ref); |
| 76 string16 SysCFStringRefToUTF16(CFStringRef ref); | 76 BASE_API string16 SysCFStringRefToUTF16(CFStringRef ref); |
| 77 std::wstring SysCFStringRefToWide(CFStringRef ref); | 77 BASE_API std::wstring SysCFStringRefToWide(CFStringRef ref); |
| 78 | 78 |
| 79 // Same, but accepts NSString input. Converts nil NSString* to the appropriate | 79 // Same, but accepts NSString input. Converts nil NSString* to the appropriate |
| 80 // string type of length 0. | 80 // string type of length 0. |
| 81 std::string SysNSStringToUTF8(NSString* ref); | 81 BASE_API std::string SysNSStringToUTF8(NSString* ref); |
| 82 string16 SysNSStringToUTF16(NSString* ref); | 82 BASE_API string16 SysNSStringToUTF16(NSString* ref); |
| 83 std::wstring SysNSStringToWide(NSString* ref); | 83 BASE_API std::wstring SysNSStringToWide(NSString* ref); |
| 84 | 84 |
| 85 #endif // defined(OS_MACOSX) | 85 #endif // defined(OS_MACOSX) |
| 86 | 86 |
| 87 } // namespace base | 87 } // namespace base |
| 88 | 88 |
| 89 #endif // BASE_SYS_STRING_CONVERSIONS_H_ | 89 #endif // BASE_SYS_STRING_CONVERSIONS_H_ |
| OLD | NEW |