mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2024-12-13 10:06:28 +01:00
9e3128fb42
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@130 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
36 lines
962 B
C++
36 lines
962 B
C++
// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
// can be found in the LICENSE file.
|
|
|
|
#include "string_util.h"
|
|
|
|
#ifdef _WIN32
|
|
|
|
std::wstring StringToWString(const std::string& s)
|
|
{
|
|
wchar_t* wch;
|
|
UINT bytes = MultiByteToWideChar(CP_ACP, 0, s.c_str(), s.size()+1, NULL, 0);
|
|
wch = new wchar_t[bytes];
|
|
if(wch)
|
|
bytes = MultiByteToWideChar(CP_ACP, 0, s.c_str(), s.size()+1, wch, bytes);
|
|
std::wstring str = wch;
|
|
delete [] wch;
|
|
return str;
|
|
}
|
|
|
|
std::string WStringToString(const std::wstring& s)
|
|
{
|
|
char* ch;
|
|
UINT bytes = WideCharToMultiByte(CP_ACP, 0, s.c_str(), s.size()+1, NULL, 0,
|
|
NULL, NULL);
|
|
ch = new char[bytes];
|
|
if(ch)
|
|
bytes = WideCharToMultiByte(CP_ACP, 0, s.c_str(), s.size()+1, ch, bytes,
|
|
NULL, NULL);
|
|
std::string str = ch;
|
|
delete [] ch;
|
|
return str;
|
|
}
|
|
|
|
#endif // _WIN32
|