failure to creat log file having unicode characters in its filepath
Logging Framework for C++
Brought to you by:
wilx
void LogImpl::setFile(const std::wstring &fileName) { log4cplus::tstring ts; ts.assign(fileName.begin(), fileName.end()); log4cplus::RollingFileAppender *rfa = new log4cplus::RollingFileAppender(ts, DMLOG_MAXSIZE_PERFILE, DMLOG_MAXFILES_FORLOG); /* ... */ }
Can you please help me understand what mistake is being done in the above steps.
What I noticed is log4cplus::tstring ts - this variable is failing to recognize unicode characters and replaces all unicode characters with alphanumerics as follows
log4cplus::tstring "/Users/<someName>/\xc1o\xdfykLO\x88/test.log"
What is your source file encoding? It seems to me that your problem happens during compilation. Assuming your locale is UTF-8 based, make sure that your source is UTF-8 encoded and that your compiler know about it. Second, make sure that your application's C++ global locale is set to your UTF-8 locale.
I compiled log4Cplus using the following command
./configure CXX="clang++ -arch i386 -stdlib=libstdc++ -DUNICODE"
The code below works for windows but not for Mac. What we observed was the fstream function which uses some sort of converter, this seems to be missing in Mac
Another simple example is the following, taken from Log4CPlus src itself, this does not work on Mac, but works on windows
Last edit: Václav Haisman 2016-08-06
Diff:
Thanks Václav Zeman appreciate your response on this bug. Would it be possible for you to provide an answer asap ?
Diff: