mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
add str
function for rune
This commit is contained in:
parent
571410dd48
commit
668646f8f9
9
examples/rune.v
Normal file
9
examples/rune.v
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fn main() {
|
||||||
|
// GRINNING FACE😀 => f0 09 98 80
|
||||||
|
grinning_face := rune(0xf09f9880)
|
||||||
|
println(grinning_face)
|
||||||
|
|
||||||
|
// COMMERCIAL AT@ => 0x40
|
||||||
|
commercial_at := rune(0x40000000)
|
||||||
|
println(commercial_at)
|
||||||
|
}
|
@ -145,10 +145,20 @@ pub fn (a []byte) contains(val byte) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO
|
pub fn (c rune) str() string {
|
||||||
fn (c rune) str() string {
|
fst_byte := int(c) >> 8 * 3 & 0xff
|
||||||
|
len := utf8_char_len(fst_byte)
|
||||||
|
mut str := string {
|
||||||
|
len: len
|
||||||
|
str: malloc(len + 1)
|
||||||
}
|
}
|
||||||
*/
|
for i := 0; i < len; i++ {
|
||||||
|
str.str[i] = int(c) >> 8 * (3 - i) & 0xff
|
||||||
|
}
|
||||||
|
str[len] = `\0`
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
pub fn (c byte) str() string {
|
pub fn (c byte) str() string {
|
||||||
mut str := string {
|
mut str := string {
|
||||||
len: 1
|
len: 1
|
||||||
|
Loading…
Reference in New Issue
Block a user