diff --git a/ports/cef/string.rs b/ports/cef/string.rs index 650407f1d20..0d0453fa438 100644 --- a/ports/cef/string.rs +++ b/ports/cef/string.rs @@ -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::() == mem::size_of::() { + 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::>(); + cef_string_wide_set(conv.as_ptr() as *const wchar_t, conv.len() as size_t, output, 1) + }) +}