mirror of
https://github.com/servo/servo.git
synced 2025-07-16 03:43:38 +01:00
embedding: cef_string_utf8_to_wide()
This commit is contained in:
parent
031963c91e
commit
8b5f4cff3d
1 changed files with 11 additions and 0 deletions
|
@ -237,3 +237,14 @@ pub extern "C" fn cef_string_wide_cmp(a: *const cef_string_wide_t, b: *const cef
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn cef_string_utf8_to_wide(src: *const u8, src_len: size_t, output: *mut cef_string_wide_t) -> c_int {
|
||||
if mem::size_of::<wchar_t>() == mem::size_of::<u16>() {
|
||||
return cef_string_utf8_to_utf16(src, src_len, output as *mut cef_string_utf16_t);
|
||||
}
|
||||
slice_to_str(src, src_len as uint, |result| {
|
||||
let conv = result.chars().map(|c| c as u32).collect::<Vec<u32>>();
|
||||
cef_string_wide_set(conv.as_ptr() as *const wchar_t, conv.len() as size_t, output, 1)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue