> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Geir Magnusson Jr.
> Sent: Wednesday, May 02, 2001 23:50
> To: [EMAIL PROTECTED]
> Subject: Re: [PATCH] Configuration
>
>
> Ilkka Priha wrote:
> >
> > Now that Velocity has nice encoding support for templates, I
> have a new wish
> > on my list. Please, be patient :). In addition to templates,
> property files
> > are frequently used for defining certain standard string
> literals in user
> > interface screens, like UI Manager skins in Turbine. Unfortunately, the
> > java.util.Properties class has a hardcoded "8859_1" encoding in
> its load()
> > method, which makes it difficult to use property files for user
> interfaces
> > of non-latin languages.
>
> Not a bad idea :)
>
> >
> > As Configuration is already an improvement to Properties, it's a perfect
> > candidate to be even better and implement a load method that supports
> > different character encodings. Below is my proposal for the job.
>
> The Configuration class is going over to Commons-collections.
>
> As I am trying to get a 0.x release out so we can share a stable jar in
> Velocity and Turbine. I would be happy to punch this in for you if you
> want...
>
> geir


Please do, that would remove, once more, one problem from my work load :)

-- Ilkka


> > --- Configuration.old   Wed May  2 20:06:04 2001
> > +++ Configuration.new   Wed May  2 20:05:15 2001
> > @@ -65,6 +65,7 @@
> >  import java.io.OutputStream;
> >  import java.io.PrintWriter;
> >  import java.io.Reader;
> > +import java.io.UnsupportedEncodingException;
> >
> >  import java.util.ArrayList;
> >  import java.util.Enumeration;
> > @@ -419,11 +420,42 @@
> >       * @param input An InputStream.
> >       * @exception IOException.
> >       */
> > -    public synchronized void load(InputStream input)
> > +    public void load(InputStream input)
> >          throws IOException
> >      {
> > -        PropertiesReader reader =
> > -            new PropertiesReader(new InputStreamReader(input));
> > +      load(input,null);
> > +    }
> > +
> > +    /**
> > +     * Load the properties from the given input stream
> > +     * and using the specified encoding.
> > +     *
> > +     * @param input An InputStream.
> > +     * @param enc An encoding.
> > +     * @exception IOException.
> > +     */
> > +    public synchronized void load(InputStream input,
> > +                                  String enc)
> > +        throws IOException
> > +    {
> > +        PropertiesReader reader = null;
> > +        if (enc != null)
> > +        {
> > +            try
> > +            {
> > +                reader =
> > +                    new PropertiesReader(new
> InputStreamReader(input,enc));
> > +            }
> > +            catch (UnsupportedEncodingException e)
> > +            {
> > +                // Get one with the default encoding...
> > +            }
> > +        }
> > +        if (reader == null)
> > +        {
> > +            reader =
> > +                new PropertiesReader(new InputStreamReader(input));
> > +        }
>
> --
> Geir Magnusson Jr.                           [EMAIL PROTECTED]
> System and Software Consulting
>
> Developing for the web?  See http://jakarta.apache.org/velocity/

Reply via email to