Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strings, bytes: Title doesn't shield against emoji #48356

Closed
180909 opened this issue Sep 13, 2021 · 6 comments
Closed

strings, bytes: Title doesn't shield against emoji #48356

180909 opened this issue Sep 13, 2021 · 6 comments
Labels
Documentation FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@180909
Copy link
Contributor

180909 commented Sep 13, 2021

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

$ go version
go version go1.17.1 darwin/arm64

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
GO111MODULE="on"
GOARCH="arm64"
GOBIN="/bin"
GOCACHE="/Users/wang/Library/Caches/go-build"
GOENV="/Users/wang/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/wang/go/pkg/mod"
GONOPROXY="gitlab.hexcloud.cn"
GONOSUMDB="gitlab.hexcloud.cn"
GOOS="darwin"
GOPATH="/Users/wang/go"
GOPRIVATE="gitlab.hexcloud.cn"
GOPROXY="https://goproxy.io,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.17.1"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/wang/open/source/go/src/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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/fc/5_f38pyn6k915kw7_vvfjhrc0000gn/T/go-build1773033347=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version go1.17.1 darwin/arm64
GOROOT/bin/go tool compile -V: compile version go1.17.1
uname -v: Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:27 PDT 2021; root:xnu-7195.141.2~5/RELEASE_ARM64_T8101
ProductName:	macOS
ProductVersion:	11.5.1
BuildVersion:	20G80
lldb --version: lldb-1205.0.28.2
Apple Swift version 5.4.2 (swiftlang-1205.0.28.2 clang-1205.0.19.57)

What did you do?

playground

What did you expect to see?

☺☻☹Hello

What did you see instead?

☺☻☹hello

@smasher164 smasher164 changed the title bytes: bytes.Title() can't shield ☺☻☹ strings, bytes: Title doesn't shield against emoji Sep 13, 2021
@smasher164
Copy link
Member

I don't see how this can be fixed without making a backwards-incompatible change for Title. I think handling emoji lies outside the scope of strings and bytes, and would warrant using something like x/text.

That being said, this seems similar to #34994, which states that Unicode punctuation should be taken into account. More generally, if we treated any rune that's not alphanumeric as a separator, this could be fixed: https://play.golang.org/p/JRe3MVsgJ_G.

/cc @ianlancetaylor @mpvl

@ianlancetaylor
Copy link
Contributor

We already have a comment on bytes.TItle saying that it doesn't handle punctuation correctly (https://pkg.go.dev/bytes#Title). Perhaps we should just extend that comment to say that it doesn't handle emoji correctly either. The function is generally problematic.

@smasher164
Copy link
Member

Given how problematic the function is, and how golang.org/x/text/cases is a better alternative for most scenarios, shouldn't bytes.Title and strings.Title be deprecated?

@ianlancetaylor
Copy link
Contributor

I would support deprecating them.

@ALTree ALTree added NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. Documentation labels Sep 14, 2021
@ALTree ALTree added this to the Unplanned milestone Sep 14, 2021
@gopherbot
Copy link

Change https://golang.org/cl/349790 mentions this issue: src/bytes: perfect bytes.Title BUG comments

@seankhliao
Copy link
Member

Title has been deprecated

@golang golang locked and limited conversation to collaborators Aug 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

6 participants