Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #6519 #6541

Closed
wants to merge 1 commit into from
Closed

Fix #6519 #6541

Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Fix #6519

  • Loading branch information
boghison committed Jul 3, 2015
commit 7cb9b08580136b5489c576cefd1a3fecc2f72b65
@@ -32,6 +32,8 @@
//! | sequences | `Vec<T>` |
//! | union types | `T` |

extern crate encoding;

use dom::bindings::codegen::PrototypeList;
use dom::bindings::error::throw_type_error;
use dom::bindings::js::Root;
@@ -64,6 +66,9 @@ use std::ptr;
use std::rc::Rc;
use core::nonzero::NonZero;

use encoding::{Encoding, DecoderTrap};
use encoding::all::UTF_16LE;

/// A trait to retrieve the constants necessary to check if a `JSObject`
/// implements a given interface.
pub trait IDLInterface {
@@ -353,9 +358,10 @@ pub fn jsstring_to_str(cx: *mut JSContext, s: *mut JSString) -> DOMString {
};
assert!(!chars.is_null());
let char_vec = unsafe {
slice::from_raw_parts(chars as *const u16, length as usize)
// length is the number of u16 elements, while we need the number of u8 bytes
slice::from_raw_parts(chars as *const u8, length*2 as usize)
};
String::from_utf16(char_vec).unwrap()
UTF_16LE.decode(char_vec, DecoderTrap::Replace).unwrap()
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.