Merge pull request #332 from nueh/master

Consider all multi-byte characters a "wordchar", fixes #329
This commit is contained in:
Zachary Yedidia
2016-09-07 12:10:24 -04:00
committed by GitHub
2 changed files with 4 additions and 4 deletions

View File

@@ -65,7 +65,7 @@ func Max(a, b int) int {
func IsWordChar(str string) bool {
if len(str) > 1 {
// Unicode
return false
return true
}
c := str[0]
return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c == '_')

View File

@@ -50,15 +50,15 @@ func TestIsWordChar(t *testing.T) {
if IsWordChar("_") == false {
t.Errorf("IsWordChar(_) = false")
}
if IsWordChar("ß") == false {
t.Errorf("IsWordChar(ß) = false")
}
if IsWordChar("~") == true {
t.Errorf("IsWordChar(~) = true")
}
if IsWordChar(" ") == true {
t.Errorf("IsWordChar( ) = true")
}
if IsWordChar("ß") == true {
t.Errorf("IsWordChar(ß) = true")
}
if IsWordChar(")") == true {
t.Errorf("IsWordChar()) = true")
}