// - if the string is not valid utf-8, it is passed through as a byte array without modification.
// - if the string is a valid ndau address, it's represented as a string.
// - if the string is valid padded base64 in the standard encoding, it is decoded and represented in the MSGP as a byte array.
// - otherwise, it is assumed to be a string, and represented as a string.
- if the string is not valid utf-8, it is passed through as a byte array without modification.
- if the string is a valid ndau address, it's represented as a string.
- if the string is valid padded base64 in the standard encoding, it is decoded and represented in the MSGP as a byte array.
- otherwise, it is assumed to be a string, and represented as a string.
// - if the string is not valid utf - 8 it is passed through as a byte array without modification . // - if the string is a valid ndau address it ' s represented as a string . // - if the string is valid padded base64 in the standard encoding it is decoded and represented in the MSGP as a byte array . // - otherwise it is assumed to be a string and represented as a string .
func (c *Converter) stringHeuristic(s string, buffer []byte) []byte {
	if !utf8.ValidString(s) {
		return msgp.AppendBytes(buffer, []byte(s))
	}
	_, err := address.Validate(s)
	if err == nil {
		return msgp.AppendString(buffer, s)
	}
	b64bytes, err := base64.StdEncoding.DecodeString(s)
	if err == nil {
		return msgp.AppendBytes(buffer, b64bytes)
	}
	return msgp.AppendString(buffer, s)
}
func ( c * Converter ) stringHeuristic ( s string , buffer [ ] byte ) [ ] byte { if ! utf8 . ValidString ( s ) { return msgp . AppendBytes ( buffer , [ ] byte ( s ) ) } _ , err := address . Validate ( s ) if err == nil { return msgp . AppendString ( buffer , s ) } b64bytes , err := base64 . StdEncoding . DecodeString ( s ) if err == nil { return msgp . AppendBytes ( buffer , b64bytes ) } return msgp . AppendString ( buffer , s ) }
if the string is not valid utf-8, it is passed through as a byte array without modification.
if the string is not valid utf - 8 it is passed through as a byte array without modification .