4 Sep 2005 02:08
something wrong with filename
Daniel Wang <btvampirex <at> yahoo.com.cn>
2005-09-04 00:08:20 GMT
2005-09-04 00:08:20 GMT
I try add the following code into dump_torrent and windows client to show chinese files correctly.
but I was defeated.
should I switch file.cpp backto file_win.cpp?
-------------------------------------------------------------------------------
1.
utf8_native(i->path.string());
2.
std::string utf8_native(std::string const& s)
{
try
{
std::wstring ws;
libtorrent::utf8_wchar(s, ws);
std::size_t size = wcstombs(0, ws.c_str(), 0);
if (size == std::size_t(-1)) return s;
std::string ret;
ret.resize(size);
size = wcstombs(&ret[0], ws.c_str(), size + 1);
if (size == wchar_t(-1)) return s;
ret.resize(size);
return ret;
}
catch(std::exception)
{
return s;
}
}
{
try
{
std::wstring ws;
libtorrent::utf8_wchar(s, ws);
std::size_t size = wcstombs(0, ws.c_str(), 0);
if (size == std::size_t(-1)) return s;
std::string ret;
ret.resize(size);
size = wcstombs(&ret[0], ws.c_str(), size + 1);
if (size == wchar_t(-1)) return s;
ret.resize(size);
return ret;
}
catch(std::exception)
{
return s;
}
}
Start your day with Yahoo! - make it your home page
RSS Feed