Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
strings: Title function incorrectly handles word breaks #6801
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
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.