Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1135

Flutter http response.body bad utf8 encoding

$
0
0

I'm starting to learn Flutter and I'm doing it by making my own manga reading app, in which I scrape all the data from the website I use the most.

My problem is that only one of the mangas I read I can't scrape the data because of this error:

FormatException (FormatException: Bad UTF-8 encoding 0x22 (at offset 369))

My scraper code:

    Future<Manga> getMangaInfo(source) async{    final response =  await _client.get(source);    var manga;    print(response.body);//error occurs here    final document = parse(response.body);    final mangaInfo = document.getElementsByClassName('tamanho-bloco-perfil');    for(Element infos in mangaInfo){      final infoCont = infos.getElementsByClassName('row');      //get titulo      Element tituloCont = infoCont[0];      final tituloH = tituloCont.getElementsByTagName('h2');      Element tituloCont2 = tituloH[0];      String titulo = '['+tituloCont2.text+']';      //print(titulo);      //get capa      Element capaCont = infoCont[2];      final capaImg = capaCont.getElementsByTagName('img');      Element capaCont2 = capaImg[0];      final capaUrl = capaCont2.attributes['src'];      //get caprecente      final capsPorNumero = document.getElementsByClassName('row lancamento-linha');      final caps = capsPorNumero[0].getElementsByTagName('a');      Element info = caps[0];      final numero = info.text.split('')[1];      final capRecenteUrl = info.attributes['href'];      manga = Manga(null,source,titulo,capaUrl,numero,capRecenteUrl);    }    return manga;  }

The response.body that gives the error

I also tried using response.bodyBytes and decoding but still can't fix it

Here's the link to the page:https://unionleitor.top/perfil-manga/kimetsu-no-yaiba

What I guess is the problem is the � character on the following meta tag on the html head

<meta name="description" content="Kimetsu no Yaiba - Novo mangá sobrenatural da Shonen Jump. O mangá conta a história de Tanjiro, o filho mais velho de uma família que �">

I couldn't find the solution yet, maybe I just looked the wrong places.Can anyone help me to solve this issue ?
Thanks!


Viewing all articles
Browse latest Browse all 1135

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>