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;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.UnsupportedCharsetException;
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 {
......@@ -305,8 +309,15 @@ public class RandomAccessCharacterFile {
}
public void setEncoding(String encoding) {
cset = (encoding == null)
? Charset.defaultCharset() : Charset.forName(encoding);
if (encoding == null) {
cset = Charset.defaultCharset();
} else {
try {
cset = Charset.forName(encoding);
} catch (UnsupportedCharsetException e) {
error(new SimpleError("Undefined encoding: " + encoding));
}
}
cdec = cset.newDecoder();
cdec.onMalformedInput(CodingErrorAction.REPLACE);
cdec.onUnmappableCharacter(CodingErrorAction.REPLACE);
......
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