From: Václav Z. <vha...@gm...> - 2012-06-06 19:38:53
|
On 06/06/2012 07:30 PM, vvv jjj wrote: > Hi log4cplus-devel Team > > Regarding Unicode support, I impemented a null codeset and imbued to > file stream as mentioned in the url > (http://forums.codeguru.com/showpost.php?p=1741409&postcount=8) in > FileAppender file in FileAppender::open method. Also changed the open > mode of stream with binary option enabled in FileAppender file. > > Please let me know if the above approach has any issues. I think that it is a viable option. Personally, I would suggest using Boost's utf8_codecvt_facet, see <http://www.boost.org/doc/libs/1_49_0/libs/serialization/doc/codecvt.html>. > > Thanks > J.Viswanath > > ------------------------------------------------------------------------ > *From:* vvv jjj <vv...@ya...> > *To:* Václav Zeman <vha...@gm...> > *Cc:* "log...@li..." > <log...@li...> > *Sent:* Friday, 1 June 2012 10:21 PM > *Subject:* Re: [Log4cplus-devel] Unicode Text Logging > > Hi log4cplus Devel Team, > > Thanks Václav Zeman for the detailed explanation. > > I understood that the problem is not with log4cplus library but it is > the behavior of stream in c++. I will try the deriving the > FileAppender and check the output or may be I change the code in > log4cplus as I'm using both RollFileAppender and DailyRollFileAppender. > > Regarding the 2nd options imbue I'm using Visual Studio 2008, so need > to check if that options work or not. > > Thanks again to log4cplus team for giving good support. > > Regards > J.Viswanath > > ------------------------------------------------------------------------ > *From:* Václav Zeman <vha...@gm...> > *To:* vvv jjj <vv...@ya...> > *Cc:* log...@li... > *Sent:* Friday, 1 June 2012 6:52 PM > *Subject:* Re: [Log4cplus-devel] Unicode Text Logging > > On 31 May 2012 19:21, Václav Zeman wrote: > > On 05/31/2012 05:46 PM, vvv jjj wrote: > >> Hi log4cplus Devel Team, > >> > >> Thanks Václav Zeman. > >> > >> I gave Unicode text directly in the cpp file. (Ex: CString str = > >> _T("Ω⅓∂₤◊");) > >> The file is saved with unicode support (the default yes button when > >> Unicode file is saved in Visual Studio 2008). The configuration used > >> is Debug Unicode dynamic library. > >>[...] > I have reproduced your problem on Windows as well. The problem is > Windows problem with its code pages. > > Even though you are using the Debug_Unicode (or Release_Unicode) > configuration, which means that the output stream is std::wfstream, > the output file is always using chars (not wchar_ts). If you insist on > logging characters outside of your Windows code page, then you are > unfortunately (nearly) out of luck for 1.0.4.1. > > The best way to work around this for 1.0.4.1 would be to derive your > own appender from *FileAppender that you use and either (1) override > its append() member function to do, either wchar_t -> UTF-8 (or any > other translation) on the fly, or, if you can use Visual Studio 2010, > (2) imbue the underlying file stream with, e.g., > std::codecvt_utf8<tchar, 0x10FFFF, > static_cast<std::codecvt_mode>(std::consume_header | > std::little_endian)> facet. > > For trunk and 1.1.x branches you can do (2) using imbue() member > function on *FileAppender. > > -- > VZ -- VZ |