ipc/chromium/src/base/sys_string_conversions.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 #ifndef BASE_SYS_STRING_CONVERSIONS_H_
michael@0 6 #define BASE_SYS_STRING_CONVERSIONS_H_
michael@0 7
michael@0 8 // Provides system-dependent string type conversions for cases where it's
michael@0 9 // necessary to not use ICU. Generally, you should not need this in Chrome,
michael@0 10 // but it is used in some shared code. Dependencies should be minimal.
michael@0 11
michael@0 12 #include <string>
michael@0 13 #include "base/basictypes.h"
michael@0 14 #include "base/string16.h"
michael@0 15
michael@0 16 class StringPiece;
michael@0 17
michael@0 18 namespace base {
michael@0 19
michael@0 20 // Converts between wide and UTF-8 representations of a string. On error, the
michael@0 21 // result is system-dependent.
michael@0 22 std::string SysWideToUTF8(const std::wstring& wide);
michael@0 23 std::wstring SysUTF8ToWide(const StringPiece& utf8);
michael@0 24
michael@0 25 // Converts between wide and the system multi-byte representations of a string.
michael@0 26 // DANGER: This will lose information and can change (on Windows, this can
michael@0 27 // change between reboots).
michael@0 28 std::string SysWideToNativeMB(const std::wstring& wide);
michael@0 29 std::wstring SysNativeMBToWide(const StringPiece& native_mb);
michael@0 30
michael@0 31 // Windows-specific ------------------------------------------------------------
michael@0 32
michael@0 33 #if defined(OS_WIN)
michael@0 34
michael@0 35 // Converts between 8-bit and wide strings, using the given code page. The
michael@0 36 // code page identifier is one accepted by the Windows function
michael@0 37 // MultiByteToWideChar().
michael@0 38 std::wstring SysMultiByteToWide(const StringPiece& mb, uint32_t code_page);
michael@0 39 std::string SysWideToMultiByte(const std::wstring& wide, uint32_t code_page);
michael@0 40
michael@0 41 #endif // defined(OS_WIN)
michael@0 42
michael@0 43 } // namespace base
michael@0 44
michael@0 45 #endif // BASE_SYS_STRING_CONVERSIONS_H_

mercurial