1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

js: add initial support for runes (#12077)

This commit is contained in:
playX
2021-10-06 10:43:49 +03:00
committed by GitHub
parent 115493781b
commit b2945e916f
10 changed files with 88 additions and 25 deletions

View File

@ -6,6 +6,16 @@ pub:
len int
}
pub fn (s string) runes() []rune {
mut runes := []rune{}
for i := 0; i < s.len; i++ {
mut r := rune(`0`)
#r = new rune(s.str[i.val].charCodeAt())
runes << r
}
return runes
}
pub fn (s string) slice(a int, b int) string {
return string(s.str.slice(a, b))
}
@ -784,7 +794,6 @@ pub fn (s string) index_any(chars string) int {
return -1
}
/*
// limit returns a portion of the string, starting at `0` and extending for a given number of characters afterward.
// 'hello'.limit(2) => 'he'
// 'hi'.limit(10) => 'hi'
@ -795,7 +804,7 @@ pub fn (s string) limit(max int) string {
}
return u[0..max].string()
}
*/
// is_title returns true if all words of the string is capitalized.
// Example: assert 'Hello V Developer'.is_title() == true
pub fn (s string) is_title() bool {