[armedbear-cvs] r11435 - trunk/j/src/org/armedbear/lisp
Erik Huelsmann
ehuelsmann at common-lisp.net
Mon Dec 8 22:35:24 UTC 2008
Author: ehuelsmann
Date: Mon Dec 8 22:35:24 2008
New Revision: 11435
Log:
Make sure we're consistently using java.nio.Charset charset names (by constructing streams
with a CharsetEncoder/CharsetDecoder argument instead of an encoding name).
Modified:
trunk/j/src/org/armedbear/lisp/Stream.java
Modified: trunk/j/src/org/armedbear/lisp/Stream.java
==============================================================================
--- trunk/j/src/org/armedbear/lisp/Stream.java (original)
+++ trunk/j/src/org/armedbear/lisp/Stream.java Mon Dec 8 22:35:24 2008
@@ -47,6 +47,7 @@
import java.io.StringWriter;
import java.io.Writer;
import java.math.BigInteger;
+import java.nio.charset.Charset;
import java.util.BitSet;
@@ -129,22 +130,14 @@
{
this.elementType = elementType;
setExternalFormat(format);
+
if (elementType == Symbol.CHARACTER || elementType == Symbol.BASE_CHAR)
{
- InputStreamReader inputStreamReader;
- try
- {
- inputStreamReader =
- (encoding == null) ?
- new InputStreamReader(inputStream)
- : new InputStreamReader(inputStream, encoding);
- }
- catch (java.io.UnsupportedEncodingException e)
- {
- Debug.trace(e);
- inputStreamReader =
- new InputStreamReader(inputStream);
- }
+ InputStreamReader inputStreamReader =
+ (encoding == null) ?
+ new InputStreamReader(inputStream)
+ : new InputStreamReader(inputStream,
+ Charset.forName(encoding).newDecoder());
initAsCharacterInputStream(new BufferedReader(inputStreamReader));
}
else
@@ -173,18 +166,11 @@
setExternalFormat(format);
if (elementType == Symbol.CHARACTER || elementType == Symbol.BASE_CHAR)
{
- Writer w;
- try
- {
- w = (encoding == null) ?
+ Writer w =
+ (encoding == null) ?
new OutputStreamWriter(outputStream)
- : new OutputStreamWriter(outputStream, encoding);
- }
- catch (java.io.UnsupportedEncodingException e)
- {
- Debug.trace(e);
- w = new OutputStreamWriter(outputStream);
- }
+ : new OutputStreamWriter(outputStream,
+ Charset.forName(encoding).newEncoder());
initAsCharacterOutputStream(w);
}
else
More information about the armedbear-cvs
mailing list