func decodeToUTF8Base64Header(input string) string {
	if !strings.Contains(input, "=?") {
		// Don't scan if there is nothing to do here
		return input
	}

	tokens := strings.FieldsFunc(input, whiteSpaceRune)
	output := make([]string, len(tokens))
	for i, token := range tokens {
		if len(token) > 4 && strings.Contains(token, "=?") {
			// Stash parenthesis, they should not be encoded
			prefix := ""
			suffix := ""
			if token[0] == '(' {
				prefix = "("
				token = token[1:]
			}
			if token[len(token)-1] == ')' {
				suffix = ")"
				token = token[:len(token)-1]
			}
			// Base64 encode token
			output[i] = prefix + mime.BEncoding.Encode("UTF-8", decodeHeader(token)) + suffix
		} else {
			output[i] = token
		}
	}

	// Return space separated tokens
	return strings.Join(output, " ")
}
func decodeToUTF8Base64Header(input string) string {
	if !strings.Contains(input, "=?") {
		// Don't scan if there is nothing to do here
		return input
	}

	tokens := strings.FieldsFunc(input, whiteSpaceRune)
	output := make([]string, len(tokens))
	for i, token := range tokens {
		if len(token) > 4 && strings.Contains(token, "=?") {
			// Stash parenthesis, they should not be encoded
			prefix := ""
			suffix := ""
			if token[0] == '(' {
				prefix = "("
				token = token[1:]
			}
			if token[len(token)-1] == ')' {
				suffix = ")"
				token = token[:len(token)-1]
			}
			// Base64 encode token
			output[i] = prefix + mime.BEncoding.Encode("UTF-8", decodeHeader(token)) + suffix
		} else {
			output[i] = token
		}
	}

	// Return space separated tokens
	return strings.Join(output, " ")
}
func decodeToUTF8Base64Header ( input string ) string { if ! strings . Contains ( input , " " ) { // Don't scan if there is nothing to do here return input } tokens := strings . FieldsFunc ( input , whiteSpaceRune ) output := make ( [ ] string , len ( tokens ) ) for i , token := range tokens { if len ( token ) > 4 && strings . Contains ( token , " " ) { // Stash parenthesis, they should not be encoded prefix := " " suffix := " " if token [ 0 ] == '(' { prefix = " " token = token [ 1 : ] } if token [ len ( token ) - 1 ] == ')' { suffix = " " token = token [ : len ( token ) - 1 ] } // Base64 encode token output [ i ] = prefix + mime . BEncoding . Encode ( " " , decodeHeader ( token ) ) + suffix } else { output [ i ] = token } } // Return space separated tokens return strings . Join ( output , " " ) }
// decodeToUTF8Base64Header decodes a MIME header per RFC 2047, reencoding to =?utf-8b?
decodeToUTF8Base64Header decodes a MIME header per RFC 2047 reencoding to = ?utf - 8b?