summaryrefslogtreecommitdiffstats
path: root/src/util/chars.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2016-09-29 22:40:22 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2016-09-29 22:40:22 +0900
commit04492bab10aeb0d081eeb8806792ccb77a8c5cb6 (patch)
treeed1543b0d1b85ac53c26e1a0ecc887328e5ea734 /src/util/chars.go
parent8b0d0342d43ed410e8542655932b60c9c0d817c6 (diff)
Use unicode.IsSpace to cover more whitespace characters
Diffstat (limited to 'src/util/chars.go')
-rw-r--r--src/util/chars.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/util/chars.go b/src/util/chars.go
index 12417c66..061120e0 100644
--- a/src/util/chars.go
+++ b/src/util/chars.go
@@ -1,6 +1,7 @@
package util
import (
+ "unicode"
"unicode/utf8"
)
@@ -63,7 +64,7 @@ func (chars *Chars) TrimLength() int {
len := chars.Length()
for i = len - 1; i >= 0; i-- {
char := chars.Get(i)
- if char != ' ' && char != '\t' {
+ if !unicode.IsSpace(char) {
break
}
}
@@ -75,7 +76,7 @@ func (chars *Chars) TrimLength() int {
var j int
for j = 0; j < len; j++ {
char := chars.Get(j)
- if char != ' ' && char != '\t' {
+ if !unicode.IsSpace(char) {
break
}
}
@@ -86,7 +87,7 @@ func (chars *Chars) TrailingWhitespaces() int {
whitespaces := 0
for i := chars.Length() - 1; i >= 0; i-- {
char := chars.Get(i)
- if char != ' ' && char != '\t' {
+ if !unicode.IsSpace(char) {
break
}
whitespaces++