|
|
@@ -111,14 +111,14 @@ func NewReader(r io.Reader, contentType string) (io.Reader, error) {
|
|
|
return r, nil
|
|
|
}
|
|
|
|
|
|
-// NewReaderByName returns a reader that converts from the specified charset to
|
|
|
-// UTF-8. It returns an error if the charset is not one of the standard
|
|
|
-// encodings for HTML. It is suitable for use as encoding/xml.Decoder's
|
|
|
-// CharsetReader function.
|
|
|
-func NewReaderByName(charset string, input io.Reader) (io.Reader, error) {
|
|
|
- e, _ := Lookup(charset)
|
|
|
+// NewReaderLabel returns a reader that converts from the specified charset to
|
|
|
+// UTF-8. It uses Lookup to find the encoding that corresponds to label, and
|
|
|
+// returns an error if Lookup returns nil. It is suitable for use as
|
|
|
+// encoding/xml.Decoder's CharsetReader function.
|
|
|
+func NewReaderLabel(label string, input io.Reader) (io.Reader, error) {
|
|
|
+ e, _ := Lookup(label)
|
|
|
if e == nil {
|
|
|
- return nil, fmt.Errorf("unsupported charset: %q", charset)
|
|
|
+ return nil, fmt.Errorf("unsupported charset: %q", label)
|
|
|
}
|
|
|
return transform.NewReader(input, e.NewDecoder()), nil
|
|
|
}
|