Return-Path: Delivered-To: apmail-avalon-cvs-archive@avalon.apache.org Received: (qmail 55132 invoked by uid 500); 15 Apr 2003 16:02:21 -0000 Mailing-List: contact cvs-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list cvs@avalon.apache.org Received: (qmail 55025 invoked by uid 500); 15 Apr 2003 16:02:20 -0000 Received: (qmail 54980 invoked from network); 15 Apr 2003 16:02:19 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 15 Apr 2003 16:02:19 -0000 Received: (qmail 72470 invoked by uid 1433); 15 Apr 2003 16:02:17 -0000 Date: 15 Apr 2003 16:02:17 -0000 Message-ID: <20030415160217.72465.qmail@icarus.apache.org> From: leif@apache.org To: avalon-logkit-cvs@apache.org Subject: cvs commit: avalon-logkit/src/java/org/apache/log/output/io StreamTarget.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N leif 2003/04/15 09:02:17 Modified: src/java/org/apache/log/output/io StreamTarget.java Log: The encoding feature added in the last commit broke logging for Japanese and other encodings which contain characters not in the US_ASCII character set. Modified so that the default encoding is used if an encoding is not specified. Revision Changes Path 1.10 +20 -7 avalon-logkit/src/java/org/apache/log/output/io/StreamTarget.java Index: StreamTarget.java =================================================================== RCS file: /home/cvs/avalon-logkit/src/java/org/apache/log/output/io/StreamTarget.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- StreamTarget.java 26 Feb 2003 08:23:02 -0000 1.9 +++ StreamTarget.java 15 Apr 2003 16:02:17 -0000 1.10 @@ -67,13 +67,10 @@ public class StreamTarget extends AbstractOutputTarget { - ///Default character encoding - private static final String DEFAULT_ENCODING = "US-ASCII"; - - ///OutputStream we are writing to + /** OutputStream we are writing to. */ private OutputStream m_outputStream; - //The encoding to use when creating byte array for string + /** The encoding to use when creating byte array for string, may be null. */ private String m_encoding; /** @@ -81,6 +78,8 @@ * * @param outputStream the OutputStream to write to * @param formatter the Formatter to use + * @param encoding Desired encoding to use when writing to the log, null + * implies the default system encoding. */ public StreamTarget( final OutputStream outputStream, final Formatter formatter, @@ -105,7 +104,12 @@ public StreamTarget( final OutputStream outputStream, final Formatter formatter ) { - this( outputStream, formatter, DEFAULT_ENCODING ); + // We can get the default system encoding by calling the following + // method, but it is not a standard API so we work around it by + // allowing encoding to be null. + // sun.io.Converters.getDefaultEncodingName(); + + this( outputStream, formatter, null ); } /** @@ -144,7 +148,16 @@ try { - outputStream.write( data.getBytes( m_encoding ) ); + byte[] bytes; + if ( m_encoding == null ) + { + bytes = data.getBytes(); + } + else + { + bytes = data.getBytes( m_encoding ); + } + outputStream.write( bytes ); outputStream.flush(); } catch( final IOException ioe ) --------------------------------------------------------------------- To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org For additional commands, e-mail: cvs-help@avalon.apache.org