Return-Path: Delivered-To: apmail-logging-log4cxx-user-archive@www.apache.org Received: (qmail 25762 invoked from network); 28 Feb 2006 07:57:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Feb 2006 07:57:30 -0000 Received: (qmail 94893 invoked by uid 500); 28 Feb 2006 07:57:28 -0000 Delivered-To: apmail-logging-log4cxx-user-archive@logging.apache.org Received: (qmail 94867 invoked by uid 500); 28 Feb 2006 07:57:27 -0000 Mailing-List: contact log4cxx-user-help@logging.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Log4CXX User" List-Id: Delivered-To: mailing list log4cxx-user@logging.apache.org Received: (qmail 94856 invoked by uid 99); 28 Feb 2006 07:57:27 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Feb 2006 23:57:27 -0800 X-ASF-Spam-Status: No, hits=4.1 required=10.0 tests=DNS_FROM_RFC_POST,RCVD_IN_SORBS_WEB,SPF_SOFTFAIL X-Spam-Check-By: apache.org Received-SPF: softfail (asf.osuosl.org: transitioning domain of carnold@houston.rr.com does not designate 68.142.198.203 as permitted sender) Received: from [68.142.198.203] (HELO smtp104.sbc.mail.mud.yahoo.com) (68.142.198.203) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 27 Feb 2006 23:57:26 -0800 Received: (qmail 12302 invoked from network); 28 Feb 2006 07:57:06 -0000 Received: from unknown (HELO ?192.168.10.100?) (curt.arnold@sbcglobal.net@70.116.113.231 with plain) by smtp104.sbc.mail.mud.yahoo.com with SMTP; 28 Feb 2006 07:57:06 -0000 Mime-Version: 1.0 (Apple Message framework v746.2) In-Reply-To: References: Content-Type: text/plain; charset=UTF-8; delsp=yes; format=flowed Message-Id: <24AFAA55-00F2-4C04-B73D-915B70E5B0C4@houston.rr.com> Content-Transfer-Encoding: quoted-printable From: Curt Arnold Subject: Re: How to write Asian character to file? Date: Tue, 28 Feb 2006 02:00:13 -0600 To: Log4CXX User X-Mailer: Apple Mail (2.746.2) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On Feb 28, 2006, at 12:29 AM, Ken wrote: > > Hi, > Forgive me if it's bothersome........ > Following is my test source code, I use setEncoding() method to =20 > set the encoding, > but the Asian character in log still can not output correctly, I =20 > only can get > question mark in file, I tried US-ASCII, ISO-8859-1, UTF-8, =20 > UTF-16BE, UTF-16LE, > UTF-16 with setEncoding() call, but all same...... > Anyone can tell me the right way to get the Asian character show =20 > in log file? > I got the SVN source code on Feb. 19, build the static lib by: > ant -Ddebug=3Dfalse - Dlib.type=3Dstatic build > > int main() > { > PatternLayoutPtr layout =3D new PatternLayout("%d{ISO8601} [%t] %=20= > l %p - %m%n"); > RollingFileAppenderPtr rfa =3D new RollingFileAppender(); > rfa->setName("sizeROLLING"); > rfa->setLayout(layout); > rfa->setFile("tsizeBased-test.log"); > > SizeBasedTriggeringPolicyPtr sbtp =3D new =20 > SizeBasedTriggeringPolicy(); > sbtp->setMaxFileSize(1024 * 1024 * 10); > > FixedWindowRollingPolicyPtr swrp =3D new = FixedWindowRollingPolicy(); > swrp->setMaxIndex(10); > swrp->setMinIndex(1); > swrp->setFileNamePattern("tsizeBased-test.log.%i"); > > rfa->setRollingPolicy(swrp); > rfa->setTriggeringPolicy(sbtp); > rfa->setEncoding("UTF-16"); > //cout << __LINE__ << ": " << rfa->getEncoding() << endl; > > Pool p; > rfa->activateOptions(p); > > LoggerPtr sizeroll =3D Logger::getLogger("sizeLogger"); > sizeroll -> setLevel(Level::DEBUG); > sizeroll -> addAppender(rfa); > > logstream lc_logstream(sizeroll, Level::DEBUG); > // lc_logstream << L"koko=E4=BD=A0=E5=A5=BDtest12+" << = LOG4CXX_ENDMSG; > lc_logstream << LOG4CXX_STR("koko=E4=BD=A0=E5=A5=BDtest34-") << = LOG4CXX_ENDMSG; > lc_logstream << LogString("koko=E4=BD=A0=E5=A5=BDtest56*") << = LOG4CXX_ENDMSG; > LOG4CXX_DEBUG(sizeroll, "koko=E4=BD=A0=E5=A5=BDtest78/"); > LOG4CXX_DEBUG(sizeroll, LOG4CXX_STR("koko=E4=BD=A0=E5=A5=BDtest78/")); > LOG4CXX_DEBUG(sizeroll, LogString("koko=E4=BD=A0=E5=A5=BDtest78/")); > > exit(1); > } > > Thanks in advance... > > > Can you reproduce the problem with a simpler appender, for example, =20 does the problem occur with a FileAppender? What platform are you running on? The code used to support character =20= encoding is different between platforms and if there is a bug, it may =20= only appear for certain platforms. Have you examined the generated files with a hex editor? There =20 should be obvious differences between a ISO-8859-1 and a UTF-16 =20 encoded file at the byte level. Obviously, the ISO-8859-1 file can =20 only output placeholder characters since it can not represent asian =20 characters. Have you had success compiling other programs containing asian string =20= literals? Are you sure that your compiler's encoding expectation is =20 correct. Could you try expliciting specifying the source code =20 encoding to the compiler (--encoding flag for gcc). What happened when you used wide literals? p.s. Using LOG4CXX_STR and LogString should not be used for log =20 requests. They represent the internal string representation in =20 log4cxx. The log request methods use the external string types =20 std::wstring and std::string. LogString may be assignment compatible =20= with the external string types, however the encoding expectations may =20= be different.=