File tree Expand file tree Collapse file tree 1 file changed +29
-6
lines changed Expand file tree Collapse file tree 1 file changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -33,9 +33,6 @@ import (
33
33
"time"
34
34
"unicode"
35
35
"unicode/utf8"
36
-
37
- "golang.org/x/text/cases"
38
- "golang.org/x/text/language"
39
36
)
40
37
41
38
//////////// Date/Time Functions ////////////
@@ -208,10 +205,36 @@ func Lcfirst(str string) string {
208
205
209
206
// Ucwords ucwords()
210
207
func Ucwords (str string ) string {
211
- caser := cases .Title (language .English )
212
- titleStr := caser .String (str )
208
+ isSeparator := func (r rune ) bool {
209
+ if r <= 0x7F {
210
+ switch {
211
+ case '0' <= r && r <= '9' :
212
+ return false
213
+ case 'a' <= r && r <= 'z' :
214
+ return false
215
+ case 'A' <= r && r <= 'Z' :
216
+ return false
217
+ case r == '_' :
218
+ return false
219
+ }
220
+ return true
221
+ }
222
+ if unicode .IsLetter (r ) || unicode .IsDigit (r ) {
223
+ return false
224
+ }
213
225
214
- return titleStr
226
+ return unicode .IsSpace (r )
227
+ }
228
+
229
+ prev := ' '
230
+ return strings .Map (func (r rune ) rune {
231
+ if isSeparator (prev ) {
232
+ prev = r
233
+ return unicode .ToTitle (r )
234
+ }
235
+ prev = r
236
+ return r
237
+ }, str )
215
238
}
216
239
217
240
// Substr substr()
You can’t perform that action at this time.
0 commit comments