mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 11:07:46 +00:00
compiler,runtime: implement string to []rune conversion
Commit message by aykevl
This commit is contained in:
committed by
Ayke van Laethem
parent
fa5855bff5
commit
e9f6e51fc8
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user