Changeset 11404


Ignore:
Timestamp:
11/30/08 13:32:16 (15 years ago)
Author:
ehuelsmann
Message:

Default to the system encoding for input/output streams when no ENCODING specified.

Note: The default/fallback encoding would be ISO-8859-1 (latin-1).

Patch by: Hideo
Tweaked by: me

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/open-external-format/src/org/armedbear/lisp/Stream.java

    r11391 r11404  
    8080   */
    8181  protected int charPos;
    82 
     82 
    8383  // Binary input.
    8484  private BufferedInputStream in;
     
    9191  }
    9292
     93  public Stream(InputStream inputStream, LispObject elementType)
     94    {
     95  this(inputStream, elementType, null);
     96    }
     97
     98
    9399  // Input stream constructors.
    94   public Stream(InputStream inputStream, LispObject elementType)
     100    public Stream(InputStream inputStream, LispObject elementType, String encoding)
    95101  {
    96102    this.elementType = elementType;
     
    102108          {
    103109            inputStreamReader =
    104               new InputStreamReader(inputStream, "ISO-8859-1");
     110                    (encoding == null) ?
     111                        new InputStreamReader(inputStream)
     112                        : new InputStreamReader(inputStream, encoding);
    105113          }
    106114        catch (java.io.UnsupportedEncodingException e)
     
    128136  }
    129137
     138  public Stream(OutputStream outputStream, LispObject elementType)
     139    {
     140  this(outputStream, elementType, null);
     141    }
     142   
    130143  // Output stream constructors.
    131   public Stream(OutputStream outputStream, LispObject elementType)
     144  public Stream(OutputStream outputStream, LispObject elementType, String encoding)
    132145  {
    133146    this.elementType = elementType;
     
    137150        try
    138151          {
    139             writer = new OutputStreamWriter(outputStream, "ISO-8859-1");
     152            writer = (encoding == null) ?
     153                new OutputStreamWriter(outputStream)
     154                : new OutputStreamWriter(outputStream, encoding);
    140155          }
    141156        catch (java.io.UnsupportedEncodingException e)
Note: See TracChangeset for help on using the changeset viewer.