leander-256 913789b972 This is a patch for the previous patch *facepalms*
I got confused somehow between the different versions of my modifications and Linux/Windows, anyway it should work now.


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2925 b45a01b8-16f6-495d-af2f-9b41ad6348cc
2010-05-16 23:59:39 +00:00

56 lines
1.3 KiB
C++

#include "util/rswin.h"
#ifdef WINDOWS_SYS
namespace librs { namespace util {
bool ConvertUtf8ToUtf16(const std::string& source, std::wstring& dest) {
int nbChars = MultiByteToWideChar(CP_UTF8, 0,
source.c_str(), -1,
0, 0);
if(nbChars == 0)
return false;
wchar_t* utf16Name = new wchar_t[nbChars];
if( MultiByteToWideChar(CP_UTF8, 0,
source.c_str(), -1,
utf16Name, nbChars) == 0) {
return false;
}
dest = utf16Name;
delete[] utf16Name;
return true;
}
bool ConvertUtf16ToUtf8(const std::wstring& source, std::string& dest) {
int nbChars = WideCharToMultiByte(CP_UTF8, 0,
source.c_str(), -1,
0, 0,
0, 0);
if(nbChars == 0)
return false;
char* utf8Name = new char[nbChars];
if( WideCharToMultiByte(CP_UTF8, 0,
source.c_str(), -1,
utf8Name, nbChars,
0, 0) == 0) {
return false;
}
dest = utf8Name;
delete[] utf8Name;
return true;
}
} } // librs::util
#endif // WINDOWS_SYS