Last active
August 29, 2015 14:07
-
-
Save zmike/acec58394071af51e3de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/ports/cef/string.rs b/ports/cef/string.rs | |
index dd1e7ae..877d6cf 100644 | |
--- a/ports/cef/string.rs | |
+++ b/ports/cef/string.rs | |
@@ -97,11 +97,16 @@ pub extern "C" fn cef_string_utf8_set(src: *const u8, src_len: size_t, output: * | |
pub extern "C" fn cef_string_utf8_to_utf16(src: *const u8, src_len: size_t, output: *mut cef_string_utf16_t) -> c | |
unsafe { | |
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(), enc.len() as size_t, output, 1); | |
- }); | |
+ match str::from_utf8(result) { | |
+ Some(enc) => { | |
+ let conv = enc.utf16_units().collect::<Vec<u16>>(); | |
+ cef_string_utf16_set(conv.as_ptr(), conv.len() as size_t, output, 1); | |
+ 1 | |
+ }, | |
+ None => { 0 } | |
+ } | |
+ }) | |
} | |
- 1 | |
} | |
#[no_mangle] | |
@@ -111,15 +116,14 @@ pub extern "C" fn cef_string_utf16_to_utf8(src: *const u16, src_len: size_t, out | |
match string::String::from_utf16(ustr) { | |
Some(str) => { | |
cef_string_utf8_set(str.as_bytes().as_ptr(), str.len() as size_t, output, 1); | |
- return 1 as c_int; | |
+ 1 as c_int | |
}, | |
None => { | |
- return 0 as c_int; | |
+ 0 as c_int | |
} | |
} | |
- }); | |
+ }) | |
} | |
- 1 | |
} | |
#[no_mangle] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment