Skip to content

Add support for double quote on item value#110

Closed
lunny wants to merge 1 commit into
go-ini:masterfrom
lunny:lunny/add_double_quote_on_val
Closed

Add support for double quote on item value#110
lunny wants to merge 1 commit into
go-ini:masterfrom
lunny:lunny/add_double_quote_on_val

Conversation

@lunny

@lunny lunny commented Jul 2, 2017

Copy link
Copy Markdown

This PR will support the format which is used on crowdin download file.

create_repo="创建了仓库 <a href=\"%s\">%s</a>"

@lunny lunny changed the title add support for double quote on item value Add support for double quote on item value Jul 2, 2017
Comment thread parser.go
if len(line) > 3 && string(line[0:3]) == `"""` {
valQuote = `"""`
} else if line[0] == '"' {
valQuote = `"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://github.com/go-ini/ini#working-with-values:

image

So this won't be supported as default behavior.

Comment thread parser.go
return p.readMultilines(line, line[startIdx:], valQuote)
}
if valQuote == `"` {
return strings.Replace(line[startIdx:pos+startIdx], `\"`, `"`, -1), nil

@unknwon unknwon Aug 13, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you distinguish user actually wants \" instead of replacing them to "?

@unknwon

unknwon commented Oct 14, 2017

Copy link
Copy Markdown
Member

You can now use this feature via:

cfg, err := ini.LoadSources(ini.LoadOptions{UnescapeValueDoubleQuotes: true}, ...))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants