diff --git a/src/InfoZIP.jl b/src/InfoZIP.jl index 7cb8c59..6b7e137 100644 --- a/src/InfoZIP.jl +++ b/src/InfoZIP.jl @@ -8,6 +8,7 @@ export open_zip, create_zip using Compat.readstring using Compat.read using Compat.write +using Compat.UTF8String if VERSION < v"0.5.0-dev+2228" Base.read(cmd::Cmd) = readbytes(cmd) end diff --git a/src/info_zip.jl b/src/info_zip.jl index 7dc8d1f..153926a 100644 --- a/src/info_zip.jl +++ b/src/info_zip.jl @@ -92,8 +92,7 @@ function Base.get(z::Archive, filename::AbstractString, default=nothing) else b = read(`unzip -qc $(z.filename) $filename`) end - return isvalid(ASCIIString, b) ? ASCIIString(b) : - isvalid(UTF8String, b) ? UTF8String(b) : b + return isvalid(UTF8String, b) ? UTF8String(b) : b end @@ -129,7 +128,7 @@ end # Read files from ZIP using iterator syntax. Base.eltype(::Type{Archive}) = - Tuple{AbstractString,Union{ByteString,Vector{UInt8},AbstractString}} + Tuple{AbstractString,Union{UTF8String,Vector{UInt8},AbstractString}} Base.keys(z::Archive) = z.keys Base.length(z::Archive) = length(z.keys) diff --git a/src/zip_file.jl b/src/zip_file.jl index 85e4b29..a1e7f20 100644 --- a/src/zip_file.jl +++ b/src/zip_file.jl @@ -19,7 +19,7 @@ function Archive(io::IO) cache = Dict() try reader = ZipFile.Reader(io, false) - cache = Dict(f.name => "" for f in reader.files) + cache = Dict([Pair(f.name, "") for f in reader.files]) end Archive(io, reader, nothing, cache, false) end @@ -138,7 +138,7 @@ end # called to read the data from the archive. Base.eltype(::Type{Archive}) = - Tuple{AbstractString,Union{ByteString,Vector{UInt8},AbstractString}} + Tuple{AbstractString,Union{UTF8String,Vector{UInt8},AbstractString}} Base.keys(z::Archive) = keys(z.cache) Base.length(z::Archive) = length(z.cache) @@ -161,8 +161,7 @@ end function readfile(io::ZipFile.ReadableFile) b = read(io) - return isvalid(ASCIIString, b) ? ASCIIString(b) : - isvalid(UTF8String, b) ? UTF8String(b) : b + return isvalid(UTF8String, b) ? UTF8String(b) : b end