zhl8670 / go-charset

Automatically exported from code.google.com/p/go-charset
0 stars 0 forks source link

Use of Fprintf in the NewWriter example #12

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If you use the example for the NewWriter provided in the docs and the string 
contains a '%', the % is used as a format string, because the signature of 
Fprintf is:

Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error)

See:

https://code.google.com/p/go-charset/source/browse/charset/example_test.go#32

What is the expected output? What do you see instead?

If I want to convert e.g. the string '100% free', I get: 100%!f(MISSING)ree.

If I use fmt.Fprint(w, s) instead of fmt.Fprintf(w, s), the result is correct. 
I think, the docs / the example should be updated.

Original issue reported on code.google.com by michael....@googlemail.com on 11 Nov 2014 at 2:42