linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #00995
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2132: just use strftime rather than its broken unicode version
------------------------------------------------------------
revno: 2132
committer: poy <poy@xxxxxxxxxx>
branch nick: repo
timestamp: Tue 2010-05-04 18:37:43 +0200
message:
just use strftime rather than its broken unicode version
modified:
changelog.txt
dcpp/Util.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt 2010-04-05 16:53:58 +0000
+++ changelog.txt 2010-05-04 16:37:43 +0000
@@ -9,6 +9,7 @@
* OpenSSL 0.9.8n - defends against a remote crash (poy)
* [L#548743] Fix broken share regression on non-Windows systems (steven sheehy)
* Fix 'Share hidden files' checkbox value saved to a wrong setting (emtee)
+* [L#562099] Fix encoding problems (poy)
-- 0.761 2010-03-14 --
* [L#533840] Fix crashes with themed menus (poy)
=== modified file 'dcpp/Util.cpp'
--- dcpp/Util.cpp 2010-04-18 04:32:43 +0000
+++ dcpp/Util.cpp 2010-05-04 16:37:43 +0000
@@ -793,40 +793,6 @@
return result;
}
-/** Fix for wide formatting bug in wcsftime in the ms c lib for multibyte encodings of unicode in singlebyte locales */
-string fixedftime(const string& format, struct tm* t) {
- string ret = format;
- const char codes[] = "aAbBcdHIjmMpSUwWxXyYzZ%";
-
- char tmp[4];
- tmp[0] = '%';
- tmp[1] = tmp[2] = tmp[3] = 0;
-
- StringMap sm;
- static const size_t BUF_SIZE = 1024;
- boost::scoped_array<char> buf(new char[BUF_SIZE]);
- for(size_t i = 0; i < strlen(codes); ++i) {
- tmp[1] = codes[i];
- tmp[2] = 0;
- strftime(&buf[0], BUF_SIZE-1, tmp, t);
- sm[tmp] = &buf[0];
-
- tmp[1] = '#';
- tmp[2] = codes[i];
- strftime(&buf[0], BUF_SIZE-1, tmp, t);
- sm[tmp] = &buf[0];
- }
-
- for(StringMapIter i = sm.begin(); i != sm.end(); ++i) {
- for(string::size_type j = ret.find(i->first); j != string::npos; j = ret.find(i->first, j)) {
- ret.replace(j, i->first.length(), i->second);
- j += i->second.length() - i->first.length();
- }
- }
-
- return ret;
-}
-
string Util::formatTime(const string &msg, const time_t t) {
if (!msg.empty()) {
size_t bufsize = msg.size() + 256;
@@ -835,19 +801,7 @@
if(!loc) {
return Util::emptyString;
}
-#if _WIN32
- tstring buf(bufsize, 0);
-
- buf.resize(_tcsftime(&buf[0], buf.size()-1, Text::toT(msg).c_str(), loc));
-
- if(buf.empty()) {
- return fixedftime(msg, loc);
- }
-
- return Text::fromT(buf);
-#else
- // will this give wide representations for %a and %A?
- // surely win32 can't have a leg up on linux/unixen in this area. - Todd
+
string buf(bufsize, 0);
buf.resize(strftime(&buf[0], bufsize-1, msg.c_str(), loc));
@@ -858,8 +812,13 @@
buf.resize(strftime(&buf[0], bufsize-1, msg.c_str(), loc));
}
- return Text::toUtf8(buf);
+#ifdef _WIN32
+ if(!Text::validateUtf8(buf))
#endif
+ {
+ buf = Text::toUtf8(buf);
+ }
+ return buf;
}
return Util::emptyString;
}