Standard library / mime
mime.WordDecoder.DecodeHeader()
Decode encoded words embedded in a header, preserving ordinary text. Unsupported charset conversion can fail; malformed words may be preserved. Expected stdout: 'Subject: café\n'.
Formal Syntax & Structure
go syntaxgo
func (d *WordDecoder) DecodeHeader(header string) (string, error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| header | string | Header text or MIME header map, according to its type. |
Return Value
(string, error)
Header with encoded words decoded, or character conversion error.
Working Example
Example Snippetgo
package main
import ( "fmt" "mime")
func main() { var d mime.WordDecoder fmt.Println(must(d.DecodeHeader("Subject: =?UTF-8?Q?caf=C3=A9?=")))}
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}