Skip to content

Commit

Permalink
[PDR-17566][feat(config)]: 配置文案调整
Browse files Browse the repository at this point in the history
  • Loading branch information
PapaPiya committed Jul 20, 2022
1 parent b75db0e commit 7204ee9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions reader/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ var (
KeyName: KeyEncoding,
ChooseOnly: true,
ChooseOptions: Encoding,
Default: "UTF-8",
Default: "自动",
DefaultNoUse: false,
Description: "编码方式(encoding)",
Advance: true,
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions reader/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
3 changes: 3 additions & 0 deletions reader/socket/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion utils/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7204ee9

Please sign in to comment.