From 448236a7b5aed00b654ebdd1868e07394f08bebf Mon Sep 17 00:00:00 2001 From: Breno Loyola Date: Thu, 23 Sep 2021 12:59:00 -0300 Subject: [PATCH] add support for other charsets --- go.mod | 1 + go.sum | 2 ++ internal/storage/xml.go | 8 +++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index cc34423..4dd632d 100644 --- a/go.mod +++ b/go.mod @@ -14,5 +14,6 @@ require ( github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect github.com/dlclark/regexp2 v1.4.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/paulrosania/go-charset v0.0.0-20190326053356-55c9d7a5834c // indirect github.com/spf13/pflag v1.0.5 // indirect ) diff --git a/go.sum b/go.sum index 8b4d7a7..69ae0e0 100644 --- a/go.sum +++ b/go.sum @@ -206,6 +206,8 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/paulrosania/go-charset v0.0.0-20190326053356-55c9d7a5834c h1:P6XGcuPTigoHf4TSu+3D/7QOQ1MbL6alNwrGhcW7sKw= +github.com/paulrosania/go-charset v0.0.0-20190326053356-55c9d7a5834c/go.mod h1:YnNlZP7l4MhyGQ4CBRwv6ohZTPrUJJZtEv4ZgADkbs4= github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ= github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/internal/storage/xml.go b/internal/storage/xml.go index dced28a..46a6ae5 100644 --- a/internal/storage/xml.go +++ b/internal/storage/xml.go @@ -3,14 +3,20 @@ package storage import ( "bytes" "fmt" - "github.com/clbanning/mxj/v2" "strings" + + "github.com/clbanning/mxj/v2" + "github.com/paulrosania/go-charset/charset" + _ "github.com/paulrosania/go-charset/data" ) func init() { // Required for https://github.com/TomWright/dasel/issues/61 mxj.XMLEscapeCharsDecoder(true) + // Required for https://github.com/TomWright/dasel/issues/164 + mxj.XmlCharsetReader = charset.NewReader + registerReadParser([]string{"xml"}, []string{".xml"}, &XMLParser{}) registerWriteParser([]string{"xml"}, []string{".xml"}, &XMLParser{}) }