Closed ghost closed 8 years ago
It does what libiconv does, that's kinda the point. Consider this snippet:
output, err := iconv.ConvertString("Am I \xfe valid?", "utf-8", "utf-8")
if err != nil {
fmt.Printf("got %s for %q\n", err, output)
}
I'm doing a utf-8 to utf-8 conversion on a string with an invalid byte sequence, the output will be:
got invalid or incomplete multibyte or wide character for "Am I "
since it stops at the first invalid sequence.
I don't believe the behavior you're suggesting is necessarily something everyone wants and should be handled by the caller.
That's a good point....I can see it both ways.
Does this library attempt to convert when the input and output encodings are the same? I wasn't able to find anything in the code but wanted to make sure I am not mistaken. For instance:
It would be more efficient to return the string unaffected.