cgen: make char literals wide (#7769)

pull/7781/head
clubby789 2021-01-01 09:06:09 +00:00 committed by GitHub
parent 8700080c4a
commit bf7da14ba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -4,3 +4,11 @@ fn test_utf8_char_len() {
s := 'п'
assert utf8_char_len(s[0]) == 2
}
fn test_utf8_wide_char() {
r := `🌎`
val := r.str().str
unsafe {
assert '${val[0]:x}${val[1]:x}${val[2]:x}${val[3]:x}' == 'f09f8c8e'
}
}

View File

@ -2452,7 +2452,7 @@ fn (mut g Gen) expr(node ast.Expr) {
if node.val == r'\`' {
g.write("'`'")
} else {
g.write("'$node.val'")
g.write("L'$node.val'")
}
}
ast.AtExpr {