<< Back to previous view

[DCODEC-2] UTF-8 characters decoding error Created: 19/Jun/14  Updated: 20/Sep/14  Resolved: 20/Sep/14

Status: Closed
Project: clojure.data.codec
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Park Sang Kyu Assignee: Alexander Taggart
Resolution: Declined Votes: 0
Labels: None

Attachments: Text File patch.txt    
Patch: Code

 Description   

When function decode! use the clojure.core.byte function to aset byte-array a value more than 127, it generate an exception like below.

"java.lang.IllegalArgumentException: Value out of range for byte: 128
RT.java:1019 clojure.lang.RT.byteCast"

You can try this by executing "(byte 128)" in repl.

This is because java doesn't hava any unsinged primitive type.
The byte type value range from -128 to 127, not from 0 to 255.

I patch a code to solve this (git diff)



 Comments   
Comment by Park Sang Kyu [ 19/Jun/14 10:21 AM ]

I have signed CA.

Comment by Alexander Taggart [ 20/Sep/14 4:24 PM ]

The encode/decode functions work on byte arrays, not character arrays, thus passing an array with values outside the byte range is considered a user error.

That said, there is forthcoming work to support string-based use cases, which may satisfy your inputs.





[DCODEC-1] Add simple utility functions for base64 conversions? Created: 11/Nov/12  Updated: 29/Mar/14

Status: Open
Project: clojure.data.codec
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Dave Sann Assignee: Alexander Taggart
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Can we add (something like) the following simple utility functions for base64 encoding/decoding ?

(defn bytes->b64str [bytes]
(String. (encode bytes)))

(defn str->b64str [s]
(bytes->b64str (.getBytes s)))

(defn b64str->bytes [b64-str]
(decode (.getBytes b64-str)))

(defn b64str->str [b64-str]
(String. (b64str->bytes b64-str)))



 Comments   
Comment by James Reeves [ 29/Mar/14 1:25 PM ]

Encoding strings might be a little edge-case, but I can certainly see a benefit to having encode-string and decode-string, or encode-str and decode-str.





Generated at Thu Oct 30 13:37:36 CDT 2014 using JIRA 4.4#649-r158309.