Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PDR-17566][feat(config)]: 配置文案调整 #1217

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 0 additions & 1 deletion reader/read.go

This file was deleted.

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