From faf42a5578e223dbac5e77489ce330b9c7155c3a Mon Sep 17 00:00:00 2001 From: papapiya <402561078@qq.com> Date: Wed, 20 Jul 2022 18:21:58 +0800 Subject: [PATCH] =?UTF-8?q?[PDR-17566][feat(config)]:=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E6=A1=88=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reader/config/config.go | 6 +++--- reader/meta.go | 3 +++ reader/read.go | 1 - reader/socket/socket.go | 3 +++ utils/models/models.go | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) delete mode 100644 reader/read.go diff --git a/reader/config/config.go b/reader/config/config.go index 5c70585a5..7e879b098 100644 --- a/reader/config/config.go +++ b/reader/config/config.go @@ -104,7 +104,7 @@ var ( KeyName: KeyEncoding, ChooseOnly: true, ChooseOptions: Encoding, - Default: "UTF-8", + Default: "自动", DefaultNoUse: false, Description: "编码方式(encoding)", Advance: true, @@ -124,10 +124,10 @@ var ( ChooseOnly: false, Default: "", DefaultNoUse: false, - Description: "读取速度限制(readio_limit)", + Description: "传输带宽限制(readio_limit)", CheckRegex: "\\d+", Advance: true, - ToolTip: "读取文件的磁盘限速,填写正整数,单位为MB/s, 默认不限速", + ToolTip: "对网络带宽传输速度进行限制,填写正整数,单位为MB/s, 默认不限速", } OptionDelimiter = Option{ KeyName: KeyDelimiter, diff --git a/reader/meta.go b/reader/meta.go index c03c02c5f..c8dd5bdc6 100644 --- a/reader/meta.go +++ b/reader/meta.go @@ -195,6 +195,9 @@ func NewMetaWithConf(conf conf.MapConf) (meta *Meta, err error) { meta.extrainfo = make(map[string]string) } decoder, _ := conf.GetStringOr(KeyEncoding, "") + if decoder == "自动" { + decoder = "UTF-8" + } if decoder != "" { meta.SetEncodingWay(strings.ToLower(decoder)) } diff --git a/reader/read.go b/reader/read.go deleted file mode 100644 index a6561bbc8..000000000 --- a/reader/read.go +++ /dev/null @@ -1 +0,0 @@ -package reader diff --git a/reader/socket/socket.go b/reader/socket/socket.go index 92958288e..b8c38783b 100644 --- a/reader/socket/socket.go +++ b/reader/socket/socket.go @@ -369,6 +369,9 @@ func NewReader(meta *reader.Meta, conf conf.MapConf) (reader.Reader, error) { } var decoder mahonia.Decoder encoding, _ := conf.GetStringOr(KeyEncoding, "") + if encoding == "自动" { + encoding = "UTF-8" + } encoding = strings.ToUpper(encoding) if encoding != DefaultEncodingWay { decoder = mahonia.NewDecoder(encoding) diff --git a/utils/models/models.go b/utils/models/models.go index e839760bd..f71232f1d 100644 --- a/utils/models/models.go +++ b/utils/models/models.go @@ -109,7 +109,7 @@ var ( // matches a plain pattern name. ie, %{NUMBER} PatternOnlyRe = regexp.MustCompile(`%{(\w+)}`) - Encoding = []interface{}{"UTF-8", "UTF-16", "US-ASCII", "ISO-8859-1", + Encoding = []interface{}{"自动", "UTF-8", "UTF-16", "US-ASCII", "ISO-8859-1", "GBK", "latin1", "GB18030", "EUC-JP", "UTF-16BE", "UTF-16LE", "Big5", "Shift_JIS", "ISO-8859-2", "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-8859-10", "ISO-8859-11", "ISO-8859-13",