blob: 555f5dd0a62066a27d0ddadbfb6125f2d2537632 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package kagus
import (
"strings"
"unicode"
)
// StringConsistsOf tests, if f returns true for all runes in s
func StringConsistsOf(s string, f func(rune) bool) bool {
for _, r := range s {
if !f(r) {
return false
}
}
return true
}
// IsASCII tests, if a Rune is in the ASCII set
func IsASCII(r rune) bool {
return (r <= unicode.MaxASCII)
}
// Indent a string s by prefixing each line with ind.
func Indent(s string, ind string) (rv string) {
ls := strings.Split(s, "\n")
first := true
for _, l := range ls {
if !first {
rv += "\n"
}
rv += ind + l
first = false
}
return
}
|