diff --git a/basis/io/encodings/iana/iana-docs.factor b/basis/io/encodings/iana/iana-docs.factor index c565d79ef5..628bceac62 100644 --- a/basis/io/encodings/iana/iana-docs.factor +++ b/basis/io/encodings/iana/iana-docs.factor @@ -9,24 +9,15 @@ ARTICLE: "io.encodings.iana" "IANA-registered encoding names" { $subsection name>encoding } { $subsection encoding>name } "To let a new encoding be used with the above words, use the following:" -{ $subsection register-encoding } -"Exceptions when encodings or names are not found:" -{ $subsection missing-encoding } -{ $subsection missing-name } ; - -HELP: missing-encoding -{ $error-description "The error called from " { $link name>encoding } " when there is no encoding descriptor registered corresponding to the given name." } ; - -HELP: missing-name -{ $error-description "The error called from " { $link encoding>name } " when there is no name registered corresponding to the given encoding." } ; +{ $subsection register-encoding } ; HELP: name>encoding { $values { "name" "an encoding name" } { "encoding" "an encoding descriptor" } } -{ $description "Given an IANA-registered encoding name, find the encoding descriptor that represents it, or " { $code f } " if it is not found (either not implemented in Factor or not registered)." } ; +{ $description "Given an IANA-registered encoding name, find the encoding descriptor that represents it, or " { $snippet "f" } " if it is not found (either not implemented in Factor or not registered)." } ; HELP: encoding>name { $values { "encoding" "an encoding descriptor" } { "name" "an encoding name" } } -{ $description "Given an encoding descriptor, return the preferred IANA name." } ; +{ $description "Given an encoding descriptor, return the preferred IANA name. If no name is found, returns " { $snippet "f" } "." } ; { name>encoding encoding>name } related-words diff --git a/basis/io/encodings/iana/iana-tests.factor b/basis/io/encodings/iana/iana-tests.factor index 3175e624ce..67b849b2b2 100644 --- a/basis/io/encodings/iana/iana-tests.factor +++ b/basis/io/encodings/iana/iana-tests.factor @@ -19,10 +19,10 @@ ebcdic-fisea "EBCDIC-FI-SE-A" register-encoding "csEBCDICFISEA" n>e-table get delete-at ebcdic-fisea e>n-table get delete-at ] unit-test -[ "EBCDIC-FI-SE-A" name>encoding ] must-fail -[ "csEBCDICFISEA" name>encoding ] must-fail -[ ebcdic-fisea encoding>name ] must-fail +[ f ] [ "EBCDIC-FI-SE-A" name>encoding ] unit-test +[ f ] [ "csEBCDICFISEA" name>encoding ] unit-test +[ f ] [ ebcdic-fisea encoding>name ] unit-test [ ebcdic-fisea "foobar" register-encoding ] must-fail -[ "foobar" name>encoding ] must-fail -[ ebcdic-fisea encoding>name ] must-fail +[ f ] [ "foobar" name>encoding ] unit-test +[ f ] [ ebcdic-fisea encoding>name ] unit-test diff --git a/basis/io/encodings/iana/iana.factor b/basis/io/encodings/iana/iana.factor index a8555ac339..b504bf854a 100644 --- a/basis/io/encodings/iana/iana.factor +++ b/basis/io/encodings/iana/iana.factor @@ -10,15 +10,11 @@ SYMBOL: e>n-table SYMBOL: aliases PRIVATE> -ERROR: missing-encoding name ; +: name>encoding ( name -- encoding/f ) + n>e-table get-global at ; -: name>encoding ( name -- encoding ) - dup n>e-table get-global at [ ] [ missing-encoding ] ?if ; - -ERROR: missing-name encoding ; - -: encoding>name ( encoding -- name ) - dup e>n-table get-global at [ ] [ missing-name ] ?if ; +: encoding>name ( encoding -- name/f ) + e>n-table get-global at ;