(data []byte, encoding string)
| 343 | } |
| 344 | |
| 345 | func decodeContent(data []byte, encoding string) []byte { |
| 346 | switch strings.ToLower(encoding) { |
| 347 | case "base64": |
| 348 | decoded, err := base64.StdEncoding.DecodeString(string(data)) |
| 349 | if err != nil { |
| 350 | return data |
| 351 | } |
| 352 | return decoded |
| 353 | case "quoted-printable": |
| 354 | decoded, err := io.ReadAll(quotedprintable.NewReader(bytes.NewReader(data))) |
| 355 | if err != nil { |
| 356 | return data |
| 357 | } |
| 358 | return decoded |
| 359 | default: |
| 360 | return data |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | // convertToUTF8 converts data from the given charset to UTF-8. |
| 365 | // If charset is empty, "utf-8", or "us-ascii", the data is returned as-is. |
no outgoing calls