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

Julius Davies commented on CODEC-94:
------------------------------------

Just making sure this isn't a regression.  Here's what I found:

- The only way to chunk the encoding in commons-codec-1.3 is via this static 
method:

{code}
// 76 character chunking is hard-coded.
// 64 character chunking is not possible!
Base64.encodeBase64Chunked( byte[] data );
{code}


- commons-codec-1.3 appends a final CRLF no matter what when using "chunked" 
mode:

[YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh
YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ==
]

[YWFhYWFhYWFhYQ==
]

[YQ==
]



Question for Lorenzo:  how would you feel about just calling new 
String().trim() yourself?

A direct byte[] trim is also possible.  Involves some System.arraycopy().  
Maybe commons-codec could even offer up such a method ( bytesTrim() ).




> unexpected CRLF at end of base64 encoded string
> -----------------------------------------------
>
>                 Key: CODEC-94
>                 URL: https://issues.apache.org/jira/browse/CODEC-94
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>         Environment: java 1.6u17
> ubuntu linux 9.10
>            Reporter: Lorenzo Ingrillì
>
> Sometimes, a base64 encoded string ends inappropriately with \r\n characters.
> In the example below, i used value 64 as line lenght and the generated base64 
> string lenght was 44; nevertheless string ends with CRLF .
> (i think, this bug is not related to bug #CODEC-89)
> How to reproduce:
> {code:title=Test.java|borderStyle=solid}
> public class Test {
>       public static void main(String args[]) throws Exception {
>               byte[] input = new byte[] {
>                               25, 109, -39, -23, 82, -47, -88, 115, 
>                               -34, 126, -57, 16, -110, -110, 60, -7, 
>                               -123, -3, 60, 91, 112, -93, -67, -65, -71,
>                               -107, 123, -15, -106, 86, -80, 79
>               };
>               Base64 b64 = new Base64(64);
>               String output = new String(b64.encode(input));
>               System.out.println("*"+output+"*");
>       }
> }
> {code}
> the output was: GW3Z6VLRqHPefscQkpI8+YX9PFtwo72/uZV78ZZWsE8=\r\n

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

Reply via email to