diff --git a/ports/cef/string.rs b/ports/cef/string.rs index 855fa1226ec..d8cf7d97531 100644 --- a/ports/cef/string.rs +++ b/ports/cef/string.rs @@ -167,6 +167,21 @@ pub extern "C" fn cef_string_utf16_set(src: *const c_ushort, src_len: size_t, ou return 1; } +#[no_mangle] +pub extern "C" fn cef_string_utf16_cmp(a: *const cef_string_utf16_t, b: *const cef_string_utf16_t) -> c_int { + unsafe { + slice::raw::buf_as_slice(mem::transmute((*a).str), (*a).length as uint, |astr:&[u16]| { + slice::raw::buf_as_slice(mem::transmute((*b).str), (*b).length as uint, |bstr:&[u16]| { + match astr.cmp(&bstr) { + Less => -1, + Equal => 0, + Greater => 1 + } + }) + }) + } +} + #[no_mangle] pub extern "C" fn cef_string_wide_clear(cs: *mut cef_string_wide_t) { unsafe {