mirror of
https://gitlab.com/news-flash/article_scraper.git
synced 2025-07-07 16:15:32 +02:00
fix encoding
This commit is contained in:
parent
bd413a795c
commit
dd958fe30f
1 changed files with 2 additions and 0 deletions
|
@ -381,6 +381,7 @@ impl FullTextParser {
|
||||||
if let Some(encoding) = Self::get_encoding_from_html(&lossy_string) {
|
if let Some(encoding) = Self::get_encoding_from_html(&lossy_string) {
|
||||||
log::debug!("Encoding extracted from HTML: '{}'", encoding);
|
log::debug!("Encoding extracted from HTML: '{}'", encoding);
|
||||||
if let Some(decoded_html) = Self::decode_html(&bytes, encoding) {
|
if let Some(decoded_html) = Self::decode_html(&bytes, encoding) {
|
||||||
|
let decoded_html = decoded_html.replace(&format!("charset=\"{encoding}\""), "charset=\"utf-8\"");
|
||||||
return Ok(decoded_html);
|
return Ok(decoded_html);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -388,6 +389,7 @@ impl FullTextParser {
|
||||||
if let Some(encoding) = Self::get_encoding_from_http_header(&headers) {
|
if let Some(encoding) = Self::get_encoding_from_http_header(&headers) {
|
||||||
log::debug!("Encoding extracted from headers: '{}'", encoding);
|
log::debug!("Encoding extracted from headers: '{}'", encoding);
|
||||||
if let Some(decoded_html) = Self::decode_html(&bytes, encoding) {
|
if let Some(decoded_html) = Self::decode_html(&bytes, encoding) {
|
||||||
|
let decoded_html = decoded_html.replace(&format!("charset=\"{encoding}\""), "charset=\"utf-8\"");
|
||||||
return Ok(decoded_html);
|
return Ok(decoded_html);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue