Signal SIMPLE-ERROR for invalid external-format arguments.

Addresses <http://abcl.org/trac/ticket/375>.
parent 10da03e9
...@@ -50,7 +50,11 @@ import java.nio.charset.CharsetDecoder; ...@@ -50,7 +50,11 @@ import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder; import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult; import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction; import java.nio.charset.CodingErrorAction;
import java.nio.charset.UnsupportedCharsetException;
import org.armedbear.lisp.Debug; import org.armedbear.lisp.Debug;
import static org.armedbear.lisp.Lisp.error;
import org.armedbear.lisp.SimpleError;
import org.armedbear.lisp.SimpleString;
public class RandomAccessCharacterFile { public class RandomAccessCharacterFile {
...@@ -305,12 +309,19 @@ public class RandomAccessCharacterFile { ...@@ -305,12 +309,19 @@ public class RandomAccessCharacterFile {
} }
public void setEncoding(String encoding) { public void setEncoding(String encoding) {
cset = (encoding == null) if (encoding == null) {
? Charset.defaultCharset() : Charset.forName(encoding); cset = Charset.defaultCharset();
cdec = cset.newDecoder(); } else {
cdec.onMalformedInput(CodingErrorAction.REPLACE); try {
cdec.onUnmappableCharacter(CodingErrorAction.REPLACE); cset = Charset.forName(encoding);
cenc = cset.newEncoder(); } catch (UnsupportedCharsetException e) {
error(new SimpleError("Undefined encoding: " + encoding));
}
}
cdec = cset.newDecoder();
cdec.onMalformedInput(CodingErrorAction.REPLACE);
cdec.onUnmappableCharacter(CodingErrorAction.REPLACE);
cenc = cset.newEncoder();
} }
public Writer getWriter() { public Writer getWriter() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment