commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Julius Davies (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CODEC-59) Add methods to Base64 which work with String instead of byte[]
Date Mon, 20 Jul 2009 16:29:14 GMT

    [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12733266#action_12733266
] 

Julius Davies commented on CODEC-59:
------------------------------------

The tests already included in the patch cover the bug.  If you accept everything in the patch
except Base64.java, I think you just need to add a test like this:


byte[] result Base64.encodeBase64(Base64TestData.DECODED, true);
byte[] expectedResult = Base64TestData.ENCODED_76_CHARS_PER_LINE.replaceAll("\n", "\r\n").getBytes("UTF-8");
assertTrue("lenChunksPerfectly", Arrays.equals(result, expectedResult));


Because Base64TestData.DECODED encodes into a multiple of 76 the original code creates an
array that is slightly too big to hold it.  The result array ends up having two 0 bytes at
the very end.

> Add methods to Base64 which work with String instead of byte[]
> --------------------------------------------------------------
>
>                 Key: CODEC-59
>                 URL: https://issues.apache.org/jira/browse/CODEC-59
>             Project: Commons Codec
>          Issue Type: Improvement
>            Reporter: Pepijn Schmitz
>            Priority: Minor
>             Fix For: 1.x
>
>         Attachments: codec59.patch
>
>
> It would be great if the Base64 class had String encode(byte[]) and byte[] decode(String)
methods. The RFC is stated in terms of "characters" for the encoding, so there should be no
problem with unwarranted assumptions with this. Currently everyone is having to convert to
and from Strings themselves.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message