core: Use encoding_rs in load_vars_loader
This adds support for BOM.
This commit is contained in:
parent
eca4ba0313
commit
1d648a1d55
|
@ -2930,6 +2930,7 @@ dependencies = [
|
|||
"bitstream-io 0.9.0",
|
||||
"chrono",
|
||||
"downcast-rs",
|
||||
"encoding_rs",
|
||||
"enumset",
|
||||
"flate2",
|
||||
"fnv",
|
||||
|
|
|
@ -33,6 +33,7 @@ json = "0.12.4"
|
|||
chrono = "0.4"
|
||||
num-traits = "0.2"
|
||||
instant = "0.1"
|
||||
encoding_rs = "0.8.26"
|
||||
|
||||
[dependencies.jpeg-decoder]
|
||||
version = "0.1.20"
|
||||
|
|
|
@ -11,6 +11,7 @@ use crate::property_map::PropertyMap;
|
|||
use crate::tag_utils::SwfMovie;
|
||||
use crate::vminterface::Instantiator;
|
||||
use crate::xml::XMLNode;
|
||||
use encoding_rs::UTF_8;
|
||||
use gc_arena::{Collect, CollectionContext, MutationContext};
|
||||
use generational_arena::{Arena, Index};
|
||||
use std::string::FromUtf8Error;
|
||||
|
@ -671,10 +672,8 @@ impl<'gc> Loader<'gc> {
|
|||
match data {
|
||||
Ok(data) => {
|
||||
// Fire the onData method with the loaded string.
|
||||
let string_data = AvmString::new(
|
||||
activation.context.gc_context,
|
||||
String::from_utf8_lossy(&data),
|
||||
);
|
||||
let string_data =
|
||||
AvmString::new(activation.context.gc_context, UTF_8.decode(&data).0);
|
||||
let _ = that.call_method("onData", &[string_data.into()], &mut activation);
|
||||
}
|
||||
Err(_) => {
|
||||
|
|
Loading…
Reference in New Issue