Problem to use GZIPReadStream

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem to use GZIPReadStream

SergeStinckwich
I try to decompress a gzip file like that:

compressed := file readStream.
stream := (GZipReadStream on: compressed) upToEnd asByteArray readStream.

​but I have the following error:
Illegal leading byte for utf-8 encoding
--
Serge Stinckwich
UMI UMMISCO 209 (SU/IRD/UY1)
"Programs must be written for people to read, and only incidentally for machines to execute."
http://www.doesnotunderstand.org/
Reply | Threaded
Open this post in threaded view
|

Re: Problem to use GZIPReadStream

Guillermo Polito
Hi Serge,

What Pharo version are you on? What is your `file` object? If `file` is a FileReference, you need to know that by default, using `readStream` provides now an encoded file (to keep backwards compatibility with what most users were doing until now).
And I think that GZip should just decode/decompress binary data.

Instead of asking it for a readStream, try asking for a `binaryReadStream`.

compressed := file binaryReadStream.
stream := (GZipReadStream on: compressed) upToEnd asByteArray readStream.

Guille

On Thu, Jun 7, 2018 at 4:41 PM, Serge Stinckwich <[hidden email]> wrote:
I try to decompress a gzip file like that:

compressed := file readStream.
stream := (GZipReadStream on: compressed) upToEnd asByteArray readStream.

​but I have the following error:
Illegal leading byte for utf-8 encoding
--
Serge Stinckwich
UMI UMMISCO 209 (SU/IRD/UY1)
"Programs must be written for people to read, and only incidentally for machines to execute."
http://www.doesnotunderstand.org/



--

   

Guille Polito

Research Engineer

Centre de Recherche en Informatique, Signal et Automatique de Lille

CRIStAL - UMR 9189

French National Center for Scientific Research - http://www.cnrs.fr


Web: http://guillep.github.io

Phone: +33 06 52 70 66 13

Reply | Threaded
Open this post in threaded view
|

Re: Problem to use GZIPReadStream

SergeStinckwich


On Thu, Jun 7, 2018 at 4:59 PM Guillermo Polito <[hidden email]> wrote:
Hi Serge,

What Pharo version are you on? What is your `file` object? If `file` is a FileReference, you need to know that by default, using `readStream` provides now an encoded file (to keep backwards compatibility with what most users were doing until now).
And I think that GZip should just decode/decompress binary data.

Instead of asking it for a readStream, try asking for a `binaryReadStream`.

compressed := file binaryReadStream.
stream := (GZipReadStream on: compressed) upToEnd asByteArray readStream.



​Thank you Guille, it works now :-)

--
Serge Stinckwich
UMI UMMISCO 209 (SU/IRD/UY1)
"Programs must be written for people to read, and only incidentally for machines to execute."
http://www.doesnotunderstand.org/