compiler,runtime: implement string to []rune conversion

Commit message by aykevl
This commit is contained in:
scriptonist
2019-06-11 21:56:28 +05:30
committed by Ayke van Laethem
parent fa5855bff5
commit e9f6e51fc8
4 changed files with 35 additions and 1 deletions
+15
View File
@@ -89,6 +89,21 @@ func stringToBytes(x _string) (slice struct {
return
}
// Convert a string to []rune slice.
func stringToRunes(s string) []rune {
var n = 0
for range s {
n++
}
var r = make([]rune, n)
n = 0
for _, e := range s {
r[n] = e
n++
}
return r
}
// Create a string from a Unicode code point.
func stringFromUnicode(x rune) _string {
array, length := encodeUTF8(x)