Replace unmaintained encoding crate with encoding_rs
This commit is contained in:
committed by
Martin Algesten
parent
a0b88926fa
commit
df1f4bd0e1
10
src/body.rs
10
src/body.rs
@@ -5,9 +5,7 @@ use std::io::{self, copy, empty, Cursor, Read, Write};
|
||||
#[cfg(feature = "charset")]
|
||||
use crate::response::DEFAULT_CHARACTER_SET;
|
||||
#[cfg(feature = "charset")]
|
||||
use encoding::label::encoding_from_whatwg_label;
|
||||
#[cfg(feature = "charset")]
|
||||
use encoding::EncoderTrap;
|
||||
use encoding_rs::Encoding;
|
||||
|
||||
#[cfg(feature = "json")]
|
||||
use super::SerdeValue;
|
||||
@@ -80,10 +78,10 @@ impl<'a> Payload<'a> {
|
||||
Payload::Text(text, _charset) => {
|
||||
#[cfg(feature = "charset")]
|
||||
let bytes = {
|
||||
let encoding = encoding_from_whatwg_label(&_charset)
|
||||
.or_else(|| encoding_from_whatwg_label(DEFAULT_CHARACTER_SET))
|
||||
let encoding = Encoding::for_label(_charset.as_bytes())
|
||||
.or_else(|| Encoding::for_label(DEFAULT_CHARACTER_SET.as_bytes()))
|
||||
.unwrap();
|
||||
encoding.encode(&text, EncoderTrap::Replace).unwrap()
|
||||
encoding.encode(&text).0
|
||||
};
|
||||
#[cfg(not(feature = "charset"))]
|
||||
let bytes = text.as_bytes();
|
||||
|
||||
Reference in New Issue
Block a user