michael@0: // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef BASE_SYS_STRING_CONVERSIONS_H_ michael@0: #define BASE_SYS_STRING_CONVERSIONS_H_ michael@0: michael@0: // Provides system-dependent string type conversions for cases where it's michael@0: // necessary to not use ICU. Generally, you should not need this in Chrome, michael@0: // but it is used in some shared code. Dependencies should be minimal. michael@0: michael@0: #include michael@0: #include "base/basictypes.h" michael@0: #include "base/string16.h" michael@0: michael@0: class StringPiece; michael@0: michael@0: namespace base { michael@0: michael@0: // Converts between wide and UTF-8 representations of a string. On error, the michael@0: // result is system-dependent. michael@0: std::string SysWideToUTF8(const std::wstring& wide); michael@0: std::wstring SysUTF8ToWide(const StringPiece& utf8); michael@0: michael@0: // Converts between wide and the system multi-byte representations of a string. michael@0: // DANGER: This will lose information and can change (on Windows, this can michael@0: // change between reboots). michael@0: std::string SysWideToNativeMB(const std::wstring& wide); michael@0: std::wstring SysNativeMBToWide(const StringPiece& native_mb); michael@0: michael@0: // Windows-specific ------------------------------------------------------------ michael@0: michael@0: #if defined(OS_WIN) michael@0: michael@0: // Converts between 8-bit and wide strings, using the given code page. The michael@0: // code page identifier is one accepted by the Windows function michael@0: // MultiByteToWideChar(). michael@0: std::wstring SysMultiByteToWide(const StringPiece& mb, uint32_t code_page); michael@0: std::string SysWideToMultiByte(const std::wstring& wide, uint32_t code_page); michael@0: michael@0: #endif // defined(OS_WIN) michael@0: michael@0: } // namespace base michael@0: michael@0: #endif // BASE_SYS_STRING_CONVERSIONS_H_