golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.98k stars 17.67k forks source link

x/text/collate: unexpected result of KeyFromString() #38726

Open wjhuang2016 opened 4 years ago

wjhuang2016 commented 4 years ago

What version of Go are you using (go version)?

$ go version
1.1.13

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
```
go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/bba/Library/Caches/go-build"
GOENV="/Users/bba/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/bba/.gvm/pkgsets/go1.13/global"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/bba/.gvm/gos/go1.13"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/bba/.gvm/gos/go1.13/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/bba/text/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/tg/tb44y2693qd2s6j53chrywyw0000gn/T/go-build299346317=/tmp/go-build -gno-record-gcc-switches -fno-common"
```

What did you do?

https://play.golang.org/p/__hCo4kcE86

What did you expect to see?

str = bytesToString(ctor.KeyFromString(buf, "L·"))
println("", str) // 1711

The str will be "17110183" instead of "1711".

What did you see instead?

"1711"

andybons commented 4 years ago

@mpvl