Skip to content

proposal: strconv: add QuoteWith or QuoteSingle #69958

@KapJI

Description

@KapJI

Proposal Details

Add QuoteWith function to allow quoting string with single quotes (\'):

func QuoteWith(s string, quote byte) string {
	return quoteWith(s, quote, false, false)
}

Alternatively, add QuoteSingle with hardcoded argument:

func QuoteSingle(s string) string {
	return quoteWith(s, '\'', false, false)
}

Currently there is UnquoteChar which supports single-quoted strings but there is no easy way to quote strings with single quotes.

Another solution for this was proposed in #34145 but it was rejected because for their case 1 there is a simple alternative. I haven't found such alternative for case 2 though.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions