|
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 |
|
3 // found in the LICENSE file. |
|
4 |
|
5 #ifndef BASE_SYS_STRING_CONVERSIONS_H_ |
|
6 #define BASE_SYS_STRING_CONVERSIONS_H_ |
|
7 |
|
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, |
|
10 // but it is used in some shared code. Dependencies should be minimal. |
|
11 |
|
12 #include <string> |
|
13 #include "base/basictypes.h" |
|
14 #include "base/string16.h" |
|
15 |
|
16 class StringPiece; |
|
17 |
|
18 namespace base { |
|
19 |
|
20 // Converts between wide and UTF-8 representations of a string. On error, the |
|
21 // result is system-dependent. |
|
22 std::string SysWideToUTF8(const std::wstring& wide); |
|
23 std::wstring SysUTF8ToWide(const StringPiece& utf8); |
|
24 |
|
25 // Converts between wide and the system multi-byte representations of a string. |
|
26 // DANGER: This will lose information and can change (on Windows, this can |
|
27 // change between reboots). |
|
28 std::string SysWideToNativeMB(const std::wstring& wide); |
|
29 std::wstring SysNativeMBToWide(const StringPiece& native_mb); |
|
30 |
|
31 // Windows-specific ------------------------------------------------------------ |
|
32 |
|
33 #if defined(OS_WIN) |
|
34 |
|
35 // Converts between 8-bit and wide strings, using the given code page. The |
|
36 // code page identifier is one accepted by the Windows function |
|
37 // MultiByteToWideChar(). |
|
38 std::wstring SysMultiByteToWide(const StringPiece& mb, uint32_t code_page); |
|
39 std::string SysWideToMultiByte(const std::wstring& wide, uint32_t code_page); |
|
40 |
|
41 #endif // defined(OS_WIN) |
|
42 |
|
43 } // namespace base |
|
44 |
|
45 #endif // BASE_SYS_STRING_CONVERSIONS_H_ |