Skip to content

x/text/width: lose one character #14817

@naduma

Description

@naduma

When Fold.String/Narrow.String was called, it was lost one character.

want := "A" + strings.Repeat("0", 127) + "B"
got := width.Fold.String("\uff21" + strings.Repeat("0", 127) + "B")
=> got != want, "B" is lost.

conditions:

  • long string (more than 128 [initialBufSize])
  • contains wide character

initialBufSize from https://github.com/golang/text/blob/master/transform/transform.go#L506

cause:

https://github.com/golang/text/blob/master/width/transform.go#L25

Even when the length of "dst" is 0, "nSrc" increases one.

InitStmt(nSrc++) is necessary?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions