mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-25 09:11:06 -04:00
Fixed utf8 issue in history manager.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4626 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c650265704
commit
363af69254
11 changed files with 248 additions and 73 deletions
|
@ -1,55 +1 @@
|
|||
#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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue