MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / setEncoding

Method setEncoding

xmlparser/decoder.go:164–177  ·  view source on GitHub ↗

setEncoding recreates the reader with the specified encoding.

(encoding string)

Source from the content-addressed store, hash-verified

162
163// setEncoding recreates the reader with the specified encoding.
164func (d *Decoder) setEncoding(encoding string) bool {
165 // Recreate the reader with the specified encoding.
166 // We are going to wrap bufio.Reader with bufio.Reader again,
167 // but non-UTF-8 encodings are rare, so this should be fine.
168 newr, err := charset.NewReaderLabel(encoding, d.r)
169 if err != nil {
170 d.err = fmt.Errorf("can't create reader for encoding %q: %w", encoding, err)
171 return false
172 }
173
174 d.setReader(newr)
175
176 return true
177}
178
179// checkBOM checks for a Byte Order Mark (BOM) at the start of the stream
180// and adjusts the reader accordingly.

Callers 2

checkBOMMethod · 0.95

Calls 2

setReaderMethod · 0.95
ErrorfMethod · 0.80

Tested by

no test coverage detected