fix bugs in convert_to/from_native() on windows
This commit is contained in:
parent
27b8c5f108
commit
91a22d48c3
|
@ -1,5 +1,6 @@
|
|||
1.0 release
|
||||
|
||||
* fix bugs in convert_to/from_native() on windows
|
||||
* fix support for web servers not supporting keepalive
|
||||
* support storing save_path in resume data
|
||||
* don't use full allocation on network drives (on windows)
|
||||
|
|
|
@ -592,6 +592,7 @@ namespace libtorrent
|
|||
ret.resize(ws.size() * 4 + 1);
|
||||
std::size_t size = WideCharToMultiByte(CP_ACP, 0, ws.c_str(), -1, &ret[0], ret.size(), NULL, NULL);
|
||||
if (size == std::size_t(-1)) return s;
|
||||
if (size != 0 && ret[size - 1] == '\0') --size;
|
||||
ret.resize(size);
|
||||
return ret;
|
||||
}
|
||||
|
@ -602,6 +603,7 @@ namespace libtorrent
|
|||
ws.resize(s.size() + 1);
|
||||
std::size_t size = MultiByteToWideChar(CP_ACP, 0, s.c_str(), -1, &ws[0], ws.size());
|
||||
if (size == std::size_t(-1)) return s;
|
||||
if (size != 0 && ret[size - 1] == '\0') --size;
|
||||
ws.resize(size);
|
||||
std::string ret;
|
||||
libtorrent::wchar_utf8(ws, ret);
|
||||
|
|
|
@ -233,6 +233,14 @@ int test_main()
|
|||
ptr = string_tokenize(next, ' ', &next);
|
||||
TEST_EQUAL(ptr, NULL);
|
||||
|
||||
TEST_EQUAL(std::string("foobar"), convert_from_native(convert_to_native("foobar")));
|
||||
TEST_EQUAL(std::string("foobar")
|
||||
, convert_from_native(convert_to_native("foo"))
|
||||
+ convert_from_native(convert_to_native("bar")));
|
||||
|
||||
TEST_EQUAL(convert_to_native("foobar")
|
||||
, convert_to_native("foo") + convert_to_native("bar"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue