[armedbear-cvs] r11404 - branches/open-external-format/src/org/armedbear/lisp

Erik Huelsmann ehuelsmann at common-lisp.net
Sun Nov 30 13:32:17 UTC 2008


Author: ehuelsmann
Date: Sun Nov 30 13:32:16 2008
New Revision: 11404

Log:
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


Modified:
   branches/open-external-format/src/org/armedbear/lisp/Stream.java

Modified: branches/open-external-format/src/org/armedbear/lisp/Stream.java
==============================================================================
--- branches/open-external-format/src/org/armedbear/lisp/Stream.java	(original)
+++ branches/open-external-format/src/org/armedbear/lisp/Stream.java	Sun Nov 30 13:32:16 2008
@@ -79,7 +79,7 @@
    * required when calling FRESH-LINE
    */
   protected int charPos;
-
+  
   // Binary input.
   private BufferedInputStream in;
 
@@ -90,8 +90,14 @@
   {
   }
 
-  // Input stream constructors.
   public Stream(InputStream inputStream, LispObject elementType)
+    {
+	this(inputStream, elementType, null);
+    }
+
+
+  // Input stream constructors.
+    public Stream(InputStream inputStream, LispObject elementType, String encoding)
   {
     this.elementType = elementType;
     if (elementType == Symbol.CHARACTER || elementType == Symbol.BASE_CHAR)
@@ -101,7 +107,9 @@
         try
           {
             inputStreamReader =
-              new InputStreamReader(inputStream, "ISO-8859-1");
+                    (encoding == null) ?
+                        new InputStreamReader(inputStream)
+                        : new InputStreamReader(inputStream, encoding);
           }
         catch (java.io.UnsupportedEncodingException e)
           {
@@ -127,8 +135,13 @@
     setInteractive(interactive);
   }
 
-  // Output stream constructors.
   public Stream(OutputStream outputStream, LispObject elementType)
+    {
+	this(outputStream, elementType, null);
+    }
+    
+  // Output stream constructors.
+  public Stream(OutputStream outputStream, LispObject elementType, String encoding)
   {
     this.elementType = elementType;
     if (elementType == Symbol.CHARACTER || elementType == Symbol.BASE_CHAR)
@@ -136,7 +149,9 @@
         isCharacterStream = true;
         try
           {
-            writer = new OutputStreamWriter(outputStream, "ISO-8859-1");
+            writer = (encoding == null) ?
+                new OutputStreamWriter(outputStream)
+                : new OutputStreamWriter(outputStream, encoding);
           }
         catch (java.io.UnsupportedEncodingException e)
           {




More information about the armedbear-cvs mailing list