Standard library / mime
mime.WordDecoder.Decode()
Decode one encoded-word, returning an error for invalid syntax. Use DecodeHeader for mixed ordinary text and encoded words. Expected stdout: 'café\n'.
Formal Syntax & Structure
go syntaxgo
func (d *WordDecoder) Decode(word string) (string, error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| word | string | Single RFC 2047 encoded-word. |
Return Value
(string, error)
Decoded UTF-8 text or error.
Working Example
Example Snippetgo
package main
import ( "fmt" "mime")
func main() { var d mime.WordDecoder; fmt.Println(must(d.Decode("=?UTF-8?B?Y2Fmw6k=?="))) }
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) }}