fix: Chinese characters are incorrectly recognized as binary. #50
This commit is contained in:
parent
ca663d8a55
commit
a6645e3340
|
@ -14,6 +14,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"tinyrdm/backend/types"
|
"tinyrdm/backend/types"
|
||||||
|
"unicode/utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConvertTo convert string to specified type
|
// ConvertTo convert string to specified type
|
||||||
|
@ -175,11 +176,18 @@ func autoToType(str string) (value, resultType string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func isBinary(str string) bool {
|
func isBinary(str string) bool {
|
||||||
for _, s := range str {
|
//buf := []byte(str)
|
||||||
if s < 0x20 || s > 0x7E {
|
//size := 0
|
||||||
|
//for start := 0; start < len(buf); start += size {
|
||||||
|
// var r rune
|
||||||
|
// if r, size = utf8.DecodeRune(buf[start:]); r == utf8.RuneError {
|
||||||
|
// return true
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
if !utf8.ValidString(str) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue