1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ipc/chromium/src/base/sys_string_conversions.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,45 @@ 1.4 +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#ifndef BASE_SYS_STRING_CONVERSIONS_H_ 1.9 +#define BASE_SYS_STRING_CONVERSIONS_H_ 1.10 + 1.11 +// Provides system-dependent string type conversions for cases where it's 1.12 +// necessary to not use ICU. Generally, you should not need this in Chrome, 1.13 +// but it is used in some shared code. Dependencies should be minimal. 1.14 + 1.15 +#include <string> 1.16 +#include "base/basictypes.h" 1.17 +#include "base/string16.h" 1.18 + 1.19 +class StringPiece; 1.20 + 1.21 +namespace base { 1.22 + 1.23 +// Converts between wide and UTF-8 representations of a string. On error, the 1.24 +// result is system-dependent. 1.25 +std::string SysWideToUTF8(const std::wstring& wide); 1.26 +std::wstring SysUTF8ToWide(const StringPiece& utf8); 1.27 + 1.28 +// Converts between wide and the system multi-byte representations of a string. 1.29 +// DANGER: This will lose information and can change (on Windows, this can 1.30 +// change between reboots). 1.31 +std::string SysWideToNativeMB(const std::wstring& wide); 1.32 +std::wstring SysNativeMBToWide(const StringPiece& native_mb); 1.33 + 1.34 +// Windows-specific ------------------------------------------------------------ 1.35 + 1.36 +#if defined(OS_WIN) 1.37 + 1.38 +// Converts between 8-bit and wide strings, using the given code page. The 1.39 +// code page identifier is one accepted by the Windows function 1.40 +// MultiByteToWideChar(). 1.41 +std::wstring SysMultiByteToWide(const StringPiece& mb, uint32_t code_page); 1.42 +std::string SysWideToMultiByte(const std::wstring& wide, uint32_t code_page); 1.43 + 1.44 +#endif // defined(OS_WIN) 1.45 + 1.46 +} // namespace base 1.47 + 1.48 +#endif // BASE_SYS_STRING_CONVERSIONS_H_