// Explode splits s into an array of UTF-8 sequences, one per Unicode character (still strings).
// Invalid UTF-8 sequences become correct encodings of U+FFF8.
func Explode(s string) []string {
- a := make([]string, utf8.RuneCountInString(s, 0, len(s)));
+ a := make([]string, utf8.RuneCountInString(s));
j := 0;
var size, rune int;
for i := 0; i < len(a); i++ {
// Count counts the number of non-overlapping instances of sep in s.
func Count(s, sep string) int {
if sep == "" {
- return utf8.RuneCountInString(s, 0, len(s))+1
+ return utf8.RuneCountInString(s)+1
}
c := sep[0];
n := 0;
}
// RuneCountInString is like RuneCount but its input is a string.
-func RuneCountInString(s string, i int, l int) int {
- ei := i + l;
+func RuneCountInString(s string) int {
+ ei := len(s);
+ i := 0;
n := 0;
for n = 0; i < ei; n++ {
if s[i] < RuneSelf {
func TestRuneCount(t *testing.T) {
for i := 0; i < len(runecounttests); i++ {
tt := runecounttests[i];
- if out := utf8.RuneCountInString(tt.in, 0, len(tt.in)); out != tt.out {
+ if out := utf8.RuneCountInString(tt.in); out != tt.out {
t.Errorf("RuneCountInString(%q) = %d, want %d", tt.in, out, tt.out);
}
if out := utf8.RuneCount(bytes(tt.in)); out != tt.out {