Skip to content

Use of Fprintf in the NewWriter example #12

@GoogleCodeExporter

Description

@GoogleCodeExporter
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions