Code Monkey home page Code Monkey logo

codecs.jl's Introduction

OSX/Linux: Build Status
pkg.julialang.org: Codecs
pkg.julialang.org: Codecs
pkg.julialang.org: Codecs
Windows: Build status

Codecs

Basic data encoding and decoding protocols.

Currently implemented protocols: Base64, Zlib, Binary Coded Decimal.

Synopsis

using Codecs

data = "Hello World!"
encoded = encode(Base64, encode(Zlib, data))
println(bytestring(encoded))

Output:

eNrzSM3JyVcIzy/KSVEEABxJBD4=

(Wow, that's inefficient.)

decoded = decode(Zlib, decode(Base64, encoded))
println(bytestring(decoded))

Output:

Hello World!

BCD is for encoding integers:

i = 2013
encoded = encode(BCD, i)
println(encoded)
encoded = encode(BCD, i, true)  # big endian digit order
println(encoded)

Output:

[0x31,0x02]
[0x20,0x13]

codecs.jl's People

Contributors

abhijithch avatar dcjones avatar kristofferc avatar mzaffalon avatar randyzwitch avatar ssfrr avatar staticfloat avatar tanmaykm avatar timholy avatar yuyichao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codecs.jl's Issues

Add 'Iterators' to METADATA.jl 'requires' file

I just tried installing the Codecs package and got a weird error that is couldn't open the module. Turns out your code imports Iterators.partition. Without declaring the dependency in METADATA, users will get the same error I got if they don't have Iterators already installed. Once the dependency is added, users installing Codecs without Iterators will have Iterators installed as well.

It's a pretty quick fix, just go to your 'requires' file in METADATA.jl, https://github.com/JuliaLang/METADATA.jl/blob/master/Codecs/versions/0.0.0/requires

Click 'Edit', type in Iterators and save.

Deprecation warning fix

diff --git a/src/Codecs.jl b/src/Codecs.jl
index b229b24..f625b3c 100644
--- a/src/Codecs.jl
+++ b/src/Codecs.jl
@@ -177,8 +177,7 @@ const Z_BUF_ERROR     = -5
 const Z_VERSION_ERROR = -6


-@unix_only const libz = "libz"
-@windows_only const libz = "zlib1"
+const libz = @static is_unix() ? "zlib" : "zlib1"

v1.1.0 Hangs Julia 0.2.1

Running julia -e 'using Codecs' with julia version 0.2.1 hangs. Works fine with julia version 0.3.0-rc1+162. I haven't had a chance to trace down exactly why but it seems to have been something in PR #7. Was this intended to break compatibility with julia 0.2.1?

base64 decoding doesn't handle newlines.

Decoding base64 text with the optional newlines will fail with the error Invalid base64 character \377. filtering out the newlines will succeed.

You would expect the base64 codec to correctly handle newlines since it's common to for base64 encoded text to have them.

Base64 encoding max string length

Hello!

I was recently working on translating an Octave script that had a custom(not library call) Base64 encoding function to Julia. In comparing the Julia Codecs implementation to the Octave function, I noticed some differences in the length of the final encoded string; Julia would take a 268 character string and the encoded length would be 268 characters, the Octave function would take a 268 character string and produce an encoded length of 272 characters.

SO, after pulling out my hair I went and did something halfway smart and looked up base64 woohoo! It looks as if the Octave function is producing Base64 transfer encoding for MIME, and is therefore applying line length maximums.

Anyway, getting to the point, would it be appropriate to submit a PR to this project that adds in the option of base64 encoding for PGP/MIME? Or do you prefer that this remains a "pure" library?

Thanks!

⚠️ Is this package still maintained? ⚠️

We are in the process of cleaning up unmaintained packages from the BioJulia repo. Unmaintained repositories can be harmful to the ecosystem for several reasons:

They reduce the findability of working packages
Users may accidentally install an unmaintained package and be frustrated when it doesn't work
In contributes to an impression that BioJulia is poorly maintained.

Is this package in a currently in a workable state with the newest version of Julia, and maintained by at least one dedicated maintainer?

If so, _simply reply to this issue that you are the maintainer, and we will close this issue. If not, we will make a pull request in approximately one month that changes the README and documentation to clearly state is it unmaintained. After yet another month, we will merge the PR, and archive the package.

[PkgEval] Your package doesn't have a test/runtests.jl file

PackageEvaluator.jl is a script that runs nightly.
It attempts to load all Julia packages and run their tests (if available) on both the stable
version of Julia (0.3) and the nightly build of the unstable version (0.4).
The results of this script are used to generate a package listing
enhanced with testing results. This service also benefits package developers by notifying them if
their package breaks for some reason (caused by e.g. changes in Julia, changes in dependencies,
or broken binary dependencies.)

Currently PackageEvaluator attempts to find your test scripts using a heuristic, preferring the
standarized test/runtests.jl whenever present. Using test/runtests.jl allows people to test
your package using simply Pkg.test("Codecs"), with any testing-only dependencies being
installed by looking at test/REQUIRE.

Your package doesn't appear to have a test/runtests.jl file. PackageEvaluator is going to move
away from auto-detecting tests and will instead only test packages with a test/runtests.jl
file. This change will take place in about a month.

You can:

  • Add the file and tag a new version. You may in fact have already added this file but not
    tagged a new version. PackageEvaluator only tests your latest tagged verison, so you must tag
    for the file to be detected.
  • Chose to do nothing. PackageEvaluator will stop attempting to test your package, and the testing
    status will be reported as "not possible".

If you'd like help or more information, please just reply to this issue.

[PkgEval] Codecs may have a testing issue on Julia 0.4 (2014-09-29)

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their tests (if available) on both the stable version of Julia (0.3) and the nightly build of the unstable version (0.4). The results of this script are used to generate a package listing enhanced with testing results.

On Julia 0.4

  • On 2014-09-28 the testing status was Tests pass.
  • On 2014-09-29 the testing status changed to Tests fail, but package loads.

Tests pass. means that PackageEvaluator found the tests for your package, executed them, and they all passed.

Tests fail, but package loads. means that PackageEvaluator found the tests for your package, executed them, and they didn't pass. However, trying to load your package with using worked.

This error on Julia 0.4 is possibly due to recently merged pull request JuliaLang/julia#8420.
This issue was filed because your testing status became worse. No additional issues will be filed if your package remains in this state, and no issue will be filed if it improves. If you'd like to opt-out of these status-change messages, reply to this message saying you'd like to and @IainNZ will add an exception. If you'd like to discuss PackageEvaluator.jl please file an issue at the repository. For example, your package may be untestable on the test machine due to a dependency - an exception can be added.

Test log:

>>> 'Pkg.add("Codecs")' log
INFO: Installing Codecs v0.1.2
INFO: Package database updated

>>> 'using Codecs' log
Julia Version 0.4.0-dev+842
Commit e5d8c1a (2014-09-29 06:50 UTC)
Platform Info:
  System: Linux (x86_64-unknown-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

>>> test log
ERROR: test error in expression: reinterpret(Int,decode(Base64,encode(Base64,reinterpret(Uint8,n)))) == n
InexactError()
 in decode at /home/idunning/pkgtest/.julia/v0.4/Codecs/src/Codecs.jl:155
 in anonymous at test.jl:83
 in do_test at test.jl:47
 in include at ./boot.jl:245
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:285
 in _start at ./client.jl:354
 in _start_3B_3625 at /home/idunning/julia04/usr/bin/../lib/julia/sys.so
while loading /home/idunning/pkgtest/.julia/v0.4/Codecs/test/tests.jl, in expression starting on line 6


>>> end of log

Package should belongs to JuliaIO

Hello BioJulia,

I'm fighting with entropy in the Julia world those days. It's becoming very,
very hard to know where to grasp a recommended / authoritative package among
Julia ones, even in 2019.

Doesn't this package would be better hosted at
JuliaIO so anyone concerned would
find it easily ?

Thanks

Issue with readme example

I am trying to run the example from the readme and it errors out:

julia> using Codecs
[ Info: Precompiling Codecs [19ecbf4d-ef7c-5e4b-b54a-0a0ff23c5aed]

julia> data = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d"
"49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d"

julia> encoded = encode(Base64, encode(Zlib, data))
92-element Array{UInt8,1}:
 0x65
 0x4e
 0x6f
 0x64
 0x53
 0x77
 0x6b
 0x4f
 0x77
 0x43
    
 0x54
 0x51
 0x6c
 0x35
 0x51
 0x68
 0x68
 0x63
 0x43

julia> println(bytestring(encoded))
ERROR: UndefVarError: bytestring not defined
Stacktrace:
 [1] top-level scope at REPL[5]:1

Adding bytestring to String method?

Is there a reason why the string method for decode (at least with base64) doesn't include bytestring?

Current:

function decode{T <: Codec}(codec::Type{T}, s::String)
    decode(codec, convert(Vector{Uint8}, s))
end

decode(Base64, "QUJDRA==")
4-element Array{Uint8,1}:
 0x41
 0x42
 0x43
 0x44

Seems like it should be:

function decode{T <: Codec}(codec::Type{T}, s::String)
    bytestring(decode(codec, convert(Vector{Uint8}, s)))
end

decode(Base64, "QUJDRA==")
"ABCD"

It feels weird to pass in a string and get returned an array. If I pass in a string that has been base64 encoded, I would expect the original input string to be returned when it's decoded, not the array representing the string.

Add SHA1, other hash functions from AWS.jl?

I've been working on building a Twitter package and needed a SHA1 function. Amit Murthy defined a bunch of functions for AWS that are probably useful to others.

Does it make sense to move those functions into Codec.jl, so that they are in a common location?

JuliaCloud/AWS.jl#16

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.