summaryrefslogtreecommitdiff
path: root/src/pkg/bytes/bytes.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/bytes/bytes.go')
-rw-r--r--src/pkg/bytes/bytes.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/pkg/bytes/bytes.go b/src/pkg/bytes/bytes.go
index 8548b1549..91ecdf947 100644
--- a/src/pkg/bytes/bytes.go
+++ b/src/pkg/bytes/bytes.go
@@ -333,3 +333,16 @@ func AddByte(s []byte, t byte) []byte {
s[lens] = t;
return s;
}
+
+// Runes returns a slice of runes (Unicode code points) equivalent to s.
+func Runes(s []byte) []int {
+ t := make([]int, utf8.RuneCount(s));
+ i := 0;
+ for len(s) > 0 {
+ r, l := utf8.DecodeRune(s);
+ t[i] = r;
+ i++;
+ s = s[l:];
+ }
+ return t;
+}