Where did code.google.com/p/go-charset/charset go?

2,105 views
Skip to first unread message

Peter Kleiweg

unread,
Oct 28, 2015, 5:07:49 PM10/28/15
to golang-nuts
I mean, it's still there, for now, but read only. And next year, you
can't get it with go get.

Is there an "official" clone on another site? I found
projects named go-charset on github.

Why isn't this in the golang.org repository? It is required for the
standard package "encoding/xml" to decode xml that isn't utf-8.
It's not even in golang.org/x/text.

James Bardin

unread,
Oct 28, 2015, 5:52:09 PM10/28/15
to golang-nuts


On Wednesday, October 28, 2015 at 5:07:49 PM UTC-4, Peter Kleiweg wrote:
I mean, it's still there, for now, but read only. And next year, you
can't get it with go get.

Is there an "official" clone on another site? I found
projects named go-charset on github.


It was Roger Peppe's code, so I assume his repo is the most "official"
 

Andy Balholm

unread,
Oct 28, 2015, 6:08:30 PM10/28/15
to Peter Kleiweg, golang-nuts
Note that the package description at https://github.com/rogpeppe/go-charset says “(superceded)”. And code.google.com/p/mahonia (my character-set conversion library) say “deprecated”. Roger Peppe doesn’t say what he recommends to use instead, but I recommend the golang.org/x/text/encoding packages. But one thing they are missing is a function to return an encoding by name. For that, you can use the NewReaderLabel function in golang.org/x/net/html/charset. It supports all the encodings supported by HTML5, and uses the implementations from x/text/encoding.

Peter Kleiweg

unread,
Oct 29, 2015, 5:26:38 AM10/29/15
to golang-nuts, pkle...@xs4all.nl
Op woensdag 28 oktober 2015 23:08:30 UTC+1 schreef Andy Balholm:

Note that the package description at https://github.com/rogpeppe/go-charset says “(superceded)”. And code.google.com/p/mahonia (my character-set conversion library) say “deprecated”. Roger Peppe doesn’t say what he recommends to use instead, but I recommend the golang.org/x/text/encoding packages. But one thing they are missing is a function to return an encoding by name. For that, you can use the NewReaderLabel function in golang.org/x/net/html/charset. It supports all the encodings supported by HTML5, and uses the implementations from x/text/encoding.

I tried with golang.org/x/text/transform, but this won't compile:

  d := xml.NewDecoder(os.Stdin)
d.CharsetReader = transform.NewReader
var t myType
err := d.Decode(&t)

I get:

    cannot use transform.NewReader (type func(io.Reader, transform.Transformer) *transform.Reader) as type func(string, io.Reader) (io.Reader, error) in assignment

Konstantin Kulikov

unread,
Oct 29, 2015, 5:52:10 AM10/29/15
to Peter Kleiweg, golang-nuts
import (
"encoding/xml"
)
dec := xml.NewDecoder(fd)
dec.CharsetReader = charset.NewReaderLabel

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

roger peppe

unread,
Oct 29, 2015, 4:57:50 PM10/29/15
to Andy Balholm, Peter Kleiweg, golang-nuts
I'll second Andy's recommendation. I haven't looked at go-charset for
a long time.

cheers,
rog.
Reply all
Reply to author
Forward
0 new messages