Skip to content

proposal: unicode/utf8: add String #30615

Description

@ianlancetaylor

Issue #3939 proposes removing the conversion from integer types to string types. In order to do that, it will be convenient if we have an exact replacement in the standard library.

I propose adding a new function to the unicode/utf8 package:

func String(r rune) string

This function will return a string containing the UTF-8 encoding of its argument.

The implementation will be equivalent to the following, though of course it may be further optimized.

func String(r rune) string {
    var a [4]byte
    return string(a[:EncodeRune(a[:], r)])
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions