diff --git a/extra/io/encodings/strict/authors.txt b/extra/io/encodings/strict/authors.txt new file mode 100644 index 0000000000..f990dd0ed2 --- /dev/null +++ b/extra/io/encodings/strict/authors.txt @@ -0,0 +1 @@ +Daniel Ehrenberg diff --git a/extra/io/encodings/strict/strict-tests.factor b/extra/io/encodings/strict/strict-tests.factor new file mode 100644 index 0000000000..aebb58cc30 --- /dev/null +++ b/extra/io/encodings/strict/strict-tests.factor @@ -0,0 +1,6 @@ +USING: io.encodings.strict io.encodings.ascii tools.test +arrays io.encodings.string ; +IN: io.encodings.strict.test + +[ { HEX: fffd } ] [ { 128 } ascii decode >array ] unit-test +[ { 128 } ascii strict decode ] must-fail diff --git a/extra/io/encodings/strict/strict.factor b/extra/io/encodings/strict/strict.factor new file mode 100644 index 0000000000..89c10d89cc --- /dev/null +++ b/extra/io/encodings/strict/strict.factor @@ -0,0 +1,18 @@ +! Copyright (C) 2008 Daniel Ehrenberg +! See http://factorcode.org/license.txt for BSD license. +USING: io.encodings kernel accessors inspector ; +IN: io.encodings.strict + +TUPLE: strict code ; +C: strict strict + +TUPLE: decode-error ; +: decode-error ( -- * ) \ decode-error construct-empty throw ; +M: decode-error summary + drop "Error in decoding input stream" ; + +M: strict + code>> [ strict ] change-code ; + +M: strict decode-char + code>> decode-char dup replacement-char = [ decode-error ] when ; diff --git a/extra/io/encodings/strict/summary.txt b/extra/io/encodings/strict/summary.txt new file mode 100644 index 0000000000..9fd0fe3bf1 --- /dev/null +++ b/extra/io/encodings/strict/summary.txt @@ -0,0 +1 @@ +Strict wrapper for encodings diff --git a/extra/io/encodings/strict/tags.txt b/extra/io/encodings/strict/tags.txt new file mode 100644 index 0000000000..8e27be7d61 --- /dev/null +++ b/extra/io/encodings/strict/tags.txt @@ -0,0 +1 @@ +text