Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transcode failing if codec is initialized #48

Open
garborg opened this issue Jan 23, 2020 · 3 comments
Open

transcode failing if codec is initialized #48

garborg opened this issue Jan 23, 2020 · 3 comments

Comments

@garborg
Copy link

garborg commented Jan 23, 2020

This looks current in the doc, but no longer (I believe this is a pattern I used before) works for me:

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.3.0 (2019-11-26)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Pkg; Pkg.status()
Project HH v0.1.0
    Status `~/src/bitbucket.org/garborg/HH/Project.toml`
  [4f18b42c] BusinessDays v0.9.6
  [944b1d66] CodecZlib v0.6.0
  [34da2185] Compat v3.2.0
  [864edb3b] DataStructures v0.17.9
  [cd3eb016] HTTP v0.8.8
  [682c06a0] JSON v0.21.0
  [6ac74813] MD5 v0.2.1
  [295af30f] Revise v2.5.0
  [ade2ca70] Dates 

julia> using CodecZlib: transcode, GzipCompressor

julia> bytes = codeunits("asfjkl")
6-element Base.CodeUnits{UInt8,String}:
 0x61
 0x73
 0x66
 0x6a
 0x6b
 0x6c

julia> transcode(GzipCompressor, bytes)
26-element Array{UInt8,1}:
 0x1f
 0x8b
 0x08
 0x00
 0x00
 0x00
 0x00
 0x00
 0x00
 0x03
 0x4b
 0x2c
 0x4e
 0xcb
 0xca
 0xce
 0x01
 0x00
 0x75
 0x9e
 0x18
 0x55
 0x06
 0x00
 0x00
 0x00

julia> transcode(GzipCompressor(), bytes)
ERROR: zlib error: <no message> (code: -2)
Stacktrace:
 [1] transcode(::GzipCompressor, ::Base.CodeUnits{UInt8,String}) at /home/sean/.julia/packages/TranscodingStreams/MsN8d/src/transcode.jl:121
 [2] top-level scope at REPL[5]:1
@ovgeorge
Copy link

ovgeorge commented Jun 8, 2020

I'm having the same issue. Had you found any solutions?

@garborg
Copy link
Author

garborg commented Jun 17, 2020

I didn't, other than using transcode(GzipCompressor, bytes) (forgoing tuning the parameters) or shelling out. I'm not actually using it now, so I didn't dig.

@evetion
Copy link

evetion commented Nov 11, 2023

The docs could use updating, I found the following by inspecting https://github.com/JuliaIO/TranscodingStreams.jl

gzip = GzipCompressor(level=9)
initialize(gzip)  # required
transcode(gzip, bytes)
finalize(gzip)  # required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants