code: func encodeWriteText(bw *bufWriter, src string, to Encoding) error {
  	if to.Equals(EncodingUTF8) {
  		bw.WriteString(src)
  		return nil
  	}
  
  	toXEncoding := resolveXEncoding(nil, to)
  	encoded, err := toXEncoding.Encoder().String(src)
  	if err != nil {
  		return err
  	}
  	bw.WriteString(encoded)
  	return nil
  }
docs: // encodeWriteText encodes src from UTF-8 to "to" encoding and writes to bw.