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

Side by Side Diff: base/sys_string_conversions.h

Issue 21473: Now that we deal with string16s, provide some useful conversions for them. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/sys_string_conversions_mac.mm » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 7
8 // Provides system-dependent string type conversions for cases where it's 8 // Provides system-dependent string type conversions for cases where it's
9 // necessary to not use ICU. Generally, you should not need this in Chrome, 9 // necessary to not use ICU. Generally, you should not need this in Chrome,
10 // but it is used in some shared code. Dependencies should be minimal. 10 // but it is used in some shared code. Dependencies should be minimal.
11 11
12 #include <string> 12 #include <string>
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/string16.h"
14 15
15 #if defined(OS_MACOSX) 16 #if defined(OS_MACOSX)
16 #include <CoreFoundation/CoreFoundation.h> 17 #include <CoreFoundation/CoreFoundation.h>
17 #ifdef __OBJC__ 18 #ifdef __OBJC__
18 @class NSString; 19 @class NSString;
19 #else 20 #else
20 class NSString; 21 class NSString;
21 #endif 22 #endif
22 #endif // OS_MACOSX 23 #endif // OS_MACOSX
23 24
(...skipping 26 matching lines...) Expand all
50 51
51 // Mac-specific ---------------------------------------------------------------- 52 // Mac-specific ----------------------------------------------------------------
52 53
53 #if defined(OS_MACOSX) 54 #if defined(OS_MACOSX)
54 55
55 // Converts between STL strings and CFStringRefs/NSStrings. 56 // Converts between STL strings and CFStringRefs/NSStrings.
56 57
57 // Creates a string, and returns it with a refcount of 1. You are responsible 58 // Creates a string, and returns it with a refcount of 1. You are responsible
58 // for releasing it. Returns NULL on failure. 59 // for releasing it. Returns NULL on failure.
59 CFStringRef SysUTF8ToCFStringRef(const std::string& utf8); 60 CFStringRef SysUTF8ToCFStringRef(const std::string& utf8);
61 CFStringRef SysUTF16ToCFStringRef(const string16& utf16);
60 CFStringRef SysWideToCFStringRef(const std::wstring& wide); 62 CFStringRef SysWideToCFStringRef(const std::wstring& wide);
61 63
62 // Same, but returns an autoreleased NSString. 64 // Same, but returns an autoreleased NSString.
63 NSString* SysUTF8ToNSString(const std::string& utf8); 65 NSString* SysUTF8ToNSString(const std::string& utf8);
66 NSString* SysUTF16ToNSString(const string16& utf16);
64 NSString* SysWideToNSString(const std::wstring& wide); 67 NSString* SysWideToNSString(const std::wstring& wide);
65 68
66 // Converts a CFStringRef to an STL string. Returns an empty string on failure. 69 // Converts a CFStringRef to an STL string. Returns an empty string on failure.
67 std::string SysCFStringRefToUTF8(CFStringRef ref); 70 std::string SysCFStringRefToUTF8(CFStringRef ref);
71 string16 SysCFStringRefToUTF16(CFStringRef ref);
68 std::wstring SysCFStringRefToWide(CFStringRef ref); 72 std::wstring SysCFStringRefToWide(CFStringRef ref);
69 73
70 // Same, but accepts NSString input. 74 // Same, but accepts NSString input.
71 std::string SysNSStringToUTF8(NSString* ref); 75 std::string SysNSStringToUTF8(NSString* ref);
76 string16 SysNSStringToUTF16(NSString* ref);
72 std::wstring SysNSStringToWide(NSString* ref); 77 std::wstring SysNSStringToWide(NSString* ref);
73 78
74 #endif // defined(OS_MACOSX) 79 #endif // defined(OS_MACOSX)
75 80
76 } // namespace base 81 } // namespace base
77 82
78 #endif // BASE_SYS_STRING_CONVERSIONS_H_ 83 #endif // BASE_SYS_STRING_CONVERSIONS_H_
OLDNEW
« no previous file with comments | « no previous file | base/sys_string_conversions_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698