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: Title function incorrectly handles word breaks #6801

Open
arbrown opened this issue Nov 20, 2013 · 7 comments
Open

strings: Title function incorrectly handles word breaks #6801

arbrown opened this issue Nov 20, 2013 · 7 comments

Comments

@arbrown
Copy link

arbrown commented Nov 20, 2013

This is a known bug, but there is no issue (that I could find) for it.

https://code.google.com/p/go/source/browse/src/pkg/strings/strings.go#485

The Title function should return a new copy of a string with each word capitalized (or,
more accurately, the first rune of each word converted to title case, which can
occasionally differ from Upper Case.)

The following sample program illustrates the incorrect current behavior:
http://play.golang.org/p/u8AJs-95-g
The Title function simply assumes any separator character (like the apostrophe, in this
case) is a word boundary.  The reality is somewhat more complicated.  For reference, see:

http://www.unicode.org/reports/tr29/
http://unicode.org/Public/UNIDATA/auxiliary/WordBreakTest.html
@robpike
Copy link
Contributor

robpike commented Nov 27, 2013

Comment 1:

It's documented in the code:
func Title(s string) string
    Title returns a copy of the string s with all Unicode letters that begin
    words mapped to their title case.
    BUG: The rule Title uses for word boundaries does not handle Unicode
    punctuation properly.
Unlikely to be fixed. Instead, perhaps the documentation should refer to a proper
implementation once it lands in go.text.
Not exactly working as intended, but working about as well as it ever will.

Labels changed: added priority-later, documentation, removed priority-triage.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 2:

Labels changed: added go1.3maybe.

@dsymonds
Copy link
Contributor

dsymonds commented Dec 2, 2013

Comment 3:

Owner changed to @robpike.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 4:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 5:

Labels changed: added repo-main.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@bradfitz bradfitz modified the milestones: Go1.8, Unplanned Sep 21, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 10, 2016
@robpike
Copy link
Contributor

robpike commented Oct 16, 2016

Not going to be fixed in 1.8.

@robpike robpike removed this from the Go1.8 milestone Oct 16, 2016
@dsnet dsnet added this to the Go1.9 milestone Nov 3, 2016
@robpike
Copy link
Contributor

robpike commented Mar 21, 2017

This is unplanned and will stay that way indefinitely. There are no plans to fix it. Please do not tag it for each Go release and do not assign it to me.

@robpike robpike removed this from the Go1.9 milestone Mar 21, 2017
@robpike robpike removed the NeedsFix The path to resolution is known, but the work has not been done. label Mar 21, 2017
@robpike robpike added this to the Unplanned milestone Mar 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants