diff options
author | Mike Blumenkrantz <zmike@osg.samsung.com> | 2014-10-12 23:35:47 -0400 |
---|---|---|
committer | Mike Blumenkrantz <zmike@osg.samsung.com> | 2014-10-12 23:36:43 -0400 |
commit | cb5d7b98bf38f648fcacec7901262003b2316c88 (patch) | |
tree | 9c5fba86a22ad0fc552e032ccabc848a4dc436b0 | |
parent | f657e76e1357bed27aeca83617f32a4c9a04168b (diff) | |
download | servo-cb5d7b98bf38f648fcacec7901262003b2316c88.tar.gz servo-cb5d7b98bf38f648fcacec7901262003b2316c88.zip |
remove rust-encoding usage from cef
-rw-r--r-- | ports/cef/lib.rs | 2 | ||||
-rw-r--r-- | ports/cef/string.rs | 10 |
2 files changed, 5 insertions, 7 deletions
diff --git a/ports/cef/lib.rs b/ports/cef/lib.rs index 00c952c005d..bf7aeec80e6 100644 --- a/ports/cef/lib.rs +++ b/ports/cef/lib.rs @@ -37,8 +37,6 @@ extern crate native; extern crate libc; extern crate "url" as std_url; -extern crate encoding; - #[cfg(target_os="macos")] extern crate core_graphics; #[cfg(target_os="macos")] diff --git a/ports/cef/string.rs b/ports/cef/string.rs index 2c3be54243e..47505f2a038 100644 --- a/ports/cef/string.rs +++ b/ports/cef/string.rs @@ -3,8 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use encoding::{Encoding, EncodeStrict}; -use encoding::all::{UTF_16LE}; use eutil::fptr_is_null; use libc::{size_t, c_int, c_ushort,c_void}; use libc::types::os::arch::c95::wchar_t; @@ -13,6 +11,7 @@ use std::mem; use std::ptr; use std::slice; use std::string; +use std::str; use types::{cef_string_utf16_t, cef_string_utf8_t, cef_string_wide_t}; use types::{cef_string_userfree_utf16_t, cef_string_userfree_utf8_t, cef_string_userfree_wide_t}; @@ -97,9 +96,10 @@ pub extern "C" fn cef_string_utf8_set(src: *const u8, src_len: size_t, output: * #[no_mangle] pub extern "C" fn cef_string_utf8_to_utf16(src: *const u8, src_len: size_t, output: *mut cef_string_utf16_t) -> c_int { unsafe { - let result = UTF_16LE.encode(string::raw::from_buf_len(src, src_len as uint).as_slice(), EncodeStrict); - if result.is_err() { return 0; } - cef_string_utf16_set(mem::transmute(result.unwrap().as_slice().as_ptr()), (src_len * 2) as size_t, output, 1); + slice::raw::buf_as_slice(src, src_len as uint, |result| { + let enc = str::from_utf8(result).unwrap().utf16_units().collect::<Vec<u16>>(); + cef_string_utf16_set(enc.as_ptr(), (src_len * 2) as size_t, output, 1); + }); } 1 } |