mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: unify const names to snake_case
This commit is contained in:
@ -109,15 +109,15 @@ pub fn (_rune string) utf32_code() int {
|
||||
}
|
||||
|
||||
const (
|
||||
CP_UTF8 = 65001
|
||||
cp_utf8 = 65001
|
||||
)
|
||||
|
||||
pub fn (_str string) to_wide() &u16 {
|
||||
$if windows {
|
||||
num_chars := (C.MultiByteToWideChar(CP_UTF8, 0, _str.str, _str.len, 0, 0))
|
||||
num_chars := (C.MultiByteToWideChar(cp_utf8, 0, _str.str, _str.len, 0, 0))
|
||||
mut wstr := &u16(malloc((num_chars + 1) * 2)) // sizeof(wchar_t)
|
||||
if wstr != 0 {
|
||||
C.MultiByteToWideChar(CP_UTF8, 0, _str.str, _str.len, wstr, num_chars)
|
||||
C.MultiByteToWideChar(cp_utf8, 0, _str.str, _str.len, wstr, num_chars)
|
||||
C.memset(&byte(wstr) + num_chars * 2, 0, 2)
|
||||
}
|
||||
return wstr
|
||||
@ -137,10 +137,10 @@ pub fn string_from_wide(_wstr &u16) string {
|
||||
|
||||
pub fn string_from_wide2(_wstr &u16, len int) string {
|
||||
$if windows {
|
||||
num_chars := C.WideCharToMultiByte(CP_UTF8, 0, _wstr, len, 0, 0, 0, 0)
|
||||
num_chars := C.WideCharToMultiByte(cp_utf8, 0, _wstr, len, 0, 0, 0, 0)
|
||||
mut str_to := malloc(num_chars + 1)
|
||||
if str_to != 0 {
|
||||
C.WideCharToMultiByte(CP_UTF8, 0, _wstr, len, str_to, num_chars, 0, 0)
|
||||
C.WideCharToMultiByte(cp_utf8, 0, _wstr, len, str_to, num_chars, 0, 0)
|
||||
C.memset(str_to + num_chars, 0, 1)
|
||||
}
|
||||
return tos2(str_to)
|
||||
@ -255,4 +255,3 @@ pub fn utf8_getchar() int {
|
||||
return uc
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user