mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Remove some usage of rust-encoding
This commit is contained in:
parent
b0c7c71729
commit
6ac106ca76
7 changed files with 8 additions and 22 deletions
|
@ -11,8 +11,6 @@ use dom::blob::{Blob, BlobImpl};
|
|||
use dom::formdata::FormData;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::promise::Promise;
|
||||
use encoding::all::UTF_8;
|
||||
use encoding::types::{DecoderTrap, Encoding};
|
||||
use js::jsapi::JSContext;
|
||||
use js::jsapi::JS_ClearPendingException;
|
||||
use js::jsapi::JS_ParseJSON;
|
||||
|
@ -110,14 +108,13 @@ fn run_package_data_algorithm<T: BodyOperations + DomObject>(object: &T,
|
|||
}
|
||||
|
||||
fn run_text_data_algorithm(bytes: Vec<u8>) -> Fallible<FetchedData> {
|
||||
let text = UTF_8.decode(&bytes, DecoderTrap::Replace).unwrap();
|
||||
Ok(FetchedData::Text(text))
|
||||
Ok(FetchedData::Text(String::from_utf8_lossy(&bytes).into_owned()))
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn run_json_data_algorithm(cx: *mut JSContext,
|
||||
bytes: Vec<u8>) -> Fallible<FetchedData> {
|
||||
let json_text = UTF_8.decode(&bytes, DecoderTrap::Replace).unwrap();
|
||||
let json_text = String::from_utf8_lossy(&bytes);
|
||||
let json_text: Vec<u16> = json_text.encode_utf16().collect();
|
||||
rooted!(in(cx) let mut rval = UndefinedValue());
|
||||
unsafe {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue