Changeset 11435


Ignore:
Timestamp:
12/08/08 22:35:24 (12 years ago)
Author:
ehuelsmann
Message:

Make sure we're consistently using java.nio.Charset charset names (by constructing streams
with a CharsetEncoder/CharsetDecoder? argument instead of an encoding name).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/Stream.java

    r11434 r11435  
    4848import java.io.Writer;
    4949import java.math.BigInteger;
     50import java.nio.charset.Charset;
    5051import java.util.BitSet;
    5152
     
    130131    this.elementType = elementType;
    131132    setExternalFormat(format);
     133   
    132134    if (elementType == Symbol.CHARACTER || elementType == Symbol.BASE_CHAR)
    133135      {
    134         InputStreamReader inputStreamReader;
    135         try
    136           {
    137             inputStreamReader =
    138                     (encoding == null) ?
    139                         new InputStreamReader(inputStream)
    140                         : new InputStreamReader(inputStream, encoding);
    141           }
    142         catch (java.io.UnsupportedEncodingException e)
    143           {
    144             Debug.trace(e);
    145             inputStreamReader =
    146               new InputStreamReader(inputStream);
    147           }
     136        InputStreamReader inputStreamReader =
     137            (encoding == null) ?
     138                new InputStreamReader(inputStream)
     139                : new InputStreamReader(inputStream,
     140                    Charset.forName(encoding).newDecoder());
    148141        initAsCharacterInputStream(new BufferedReader(inputStreamReader));
    149142      }
     
    174167    if (elementType == Symbol.CHARACTER || elementType == Symbol.BASE_CHAR)
    175168      {
    176   Writer w;
    177         try
    178           {
    179             w = (encoding == null) ?
     169  Writer w =
     170            (encoding == null) ?
    180171                new OutputStreamWriter(outputStream)
    181                 : new OutputStreamWriter(outputStream, encoding);
    182           }
    183         catch (java.io.UnsupportedEncodingException e)
    184           {
    185             Debug.trace(e);
    186             w = new OutputStreamWriter(outputStream);
    187           }
     172                : new OutputStreamWriter(outputStream,
     173                    Charset.forName(encoding).newEncoder());
    188174  initAsCharacterOutputStream(w);
    189175      }
Note: See TracChangeset for help on using the changeset viewer.