arrow_back Guzzle cannot work with windows-1250 (loses Polish letters)?

1 vote
I use guzzle("guzzlehttp/guzzle": "^7.2") to download the main page of (Polish) with a simple request.
$r = $client->request('GET', '');
$body = $r->getBody();
$bodyContent = $body->getContents();
file_put_contents('body.htm', $bodyContent);
The encoding is not in the header, but it is in the body of the Windows-1250 page. The problem is that the Polish letters are lost. The headline is in the original on the website: Najważniejsze wiadomości gospodarcze, prawne i polityczne z Polski i ze świata. Aktualne wiadomości z dnia -
The headline I get: Najwa¿niejsze wiadomoœci gospodarcze, prawne i polityczne z Polski i ze œwiata. Aktualne wiadomoœci z dnia -

1 Answer

0 votes
$data = mb_convert_encoding($bodyContent, 'UTF-8', mb_detect_encoding($bodyContent));
file_put_contents('body.htm', $data);

1 comment

Same thing.
PHP Warning:  mb_convert_encoding(): Illegal character encoding specified