You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Pepijn Schmitz (JIRA)" <ji...@apache.org> on 2007/11/16 13:31:49 UTC

[jira] Created: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

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: New Feature
            Reporter: Pepijn Schmitz
            Priority: Minor


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.


[jira] Updated: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julius Davies updated CODEC-59:
-------------------------------

    Comment: was deleted

(was: I do have a patch ready for this, but it's waiting for CODEC-81 first.  (There are conflicts, so I have to wait.))

> 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-but-only-after-codec81.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.


[jira] Issue Comment Edited: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12732788#action_12732788 ] 

Julius Davies edited comment on CODEC-59 at 7/17/09 4:40 PM:
-------------------------------------------------------------

codec59.patch attached.  It introduces two new methods:

public String Base64.encodeToString( byte[] b )

public byte[] Base64.decodeFromString( String s )


The String the first method produces chunks the output into 76-character lines.  If consumers want very-long single lines instead they can run .replaceAll("\r\n", "") against the output.  (I chose chunking as default behaviour because starting with a very-long-line and breaking it into chunks is more of a pain).

Even if this patch is not accepted, I strongly recommend taking in these 5 lines, since they fix a very subtle and rare bug (newly introduced in CODEC-69 I suspect):

{code}
@@ -698,7 +715,11 @@
             len += 4 - mod;
         }
         if (isChunked) {
-            len += (1 + (len / CHUNK_SIZE)) * CHUNK_SEPARATOR.length;
+            boolean lenChunksPerfectly = len % CHUNK_SIZE == 0;
+            len += (len / CHUNK_SIZE) * CHUNK_SEPARATOR.length;
+            if (!lenChunksPerfectly) {
+                len += CHUNK_SEPARATOR.length;
+            }
         }
{code}


      was (Author: juliusdavies):
    codec59.patch attached.  It introduces two new methods:

public String Base64.encodeToString( byte[] b )

public byte[] Base64.decodeFromString( String s )


The String the first method produces chunks the output into 76-character lines.  If consumers want very-long single lines instead they can run .replaceAll("\r\n", "") against the output.  (I chose chunking as default behaviour because the breaking a very-long-line into chunks is quite a bit trickier).

Even if this patch is not accepted, I strongly recommend taking in these 5 lines, since they fix a very subtle and rare bug (newly introduced in CODEC-69 I suspect):

{code}
@@ -698,7 +715,11 @@
             len += 4 - mod;
         }
         if (isChunked) {
-            len += (1 + (len / CHUNK_SIZE)) * CHUNK_SEPARATOR.length;
+            boolean lenChunksPerfectly = len % CHUNK_SIZE == 0;
+            len += (len / CHUNK_SIZE) * CHUNK_SEPARATOR.length;
+            if (!lenChunksPerfectly) {
+                len += CHUNK_SEPARATOR.length;
+            }
         }
{code}

  
> 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.


[jira] Updated: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell updated CODEC-59:
-------------------------------

    Fix Version/s: 1.4

> 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: New Feature
>            Reporter: Pepijn Schmitz
>            Priority: Minor
>             Fix For: 1.4
>
>
> 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.


[jira] Updated: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julius Davies updated CODEC-59:
-------------------------------

    Attachment:     (was: codec59-but-only-after-codec81.patch)

> 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-2009-07-28.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.


[jira] Updated: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julius Davies updated CODEC-59:
-------------------------------

    Attachment: codec59.patch

codec59.patch attached.  It introduces two new methods:

public String Base64.encodeToString( byte[] b )

public byte[] Base64.decodeFromString( String s )


The String the first method produces chunks the output into 76-character lines.  If consumers want very-long single lines instead they can run .replaceAll("\r\n", "") against the output.  (I chose chunking as default behaviour because the breaking a very-long-line into chunks is quite a bit trickier).

Even if this patch is not accepted, I strongly recommend taking in these 5 lines, since they fix a very subtle and rare bug (newly introduced in CODEC-69 I suspect):

@@ -698,7 +715,11 @@
             len += 4 - mod;
         }
         if (isChunked) {
-            len += (1 + (len / CHUNK_SIZE)) * CHUNK_SEPARATOR.length;
+            boolean lenChunksPerfectly = len % CHUNK_SIZE == 0;
+            len += (len / CHUNK_SIZE) * CHUNK_SEPARATOR.length;
+            if (!lenChunksPerfectly) {
+                len += CHUNK_SEPARATOR.length;
+            }
         }



> 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.


[jira] Updated: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell updated CODEC-59:
-------------------------------

    Fix Version/s:     (was: 1.4)
                   1.x

No patches to date, so moving out of the 1.4 release plan.

> 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
>
>
> 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.


[jira] Updated: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julius Davies updated CODEC-59:
-------------------------------

    Attachment:     (was: codec59_2009-07-26.patch)

> 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
>
>
> 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.


[jira] Commented: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12733013#action_12733013 ] 

Gary Gregory commented on CODEC-59:
-----------------------------------

About the "5 lines" fix: can you provide a test that shows the bug. It would be good to see a test to address this fix specifically.

> 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.


[jira] Commented: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Pepijn Schmitz (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12543090 ] 

Pepijn Schmitz commented on CODEC-59:
-------------------------------------

Right, that's exactly what I meant and wrote. The codec could encode bytes TO Strings (with a String encode(byte[]) method) and decode bytes FROM Strings (with a byte[] decode(String) method). These Strings would only contain characters from the base 64 character set (which is a subset of ASCII).

> 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: New Feature
>            Reporter: Pepijn Schmitz
>            Priority: Minor
>
> 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.


[jira] Commented: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Razan Abbass (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12919676#action_12919676 ] 

Razan Abbass commented on CODEC-59:
-----------------------------------

[airline tickets|http://getflightsto.com]
[Parenting|http://childcareforums.com]


> 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.4
>
>         Attachments: codec59-2009-07-28.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.


[jira] Updated: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julius Davies updated CODEC-59:
-------------------------------

    Attachment: codec59-but-only-after-codec81.patch

Attached file (codec59-but-only-after-codec81.patch) seems to work!

> 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-but-only-after-codec81.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.


[jira] Issue Comment Edited: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12732788#action_12732788 ] 

Julius Davies edited comment on CODEC-59 at 7/17/09 4:38 PM:
-------------------------------------------------------------

codec59.patch attached.  It introduces two new methods:

public String Base64.encodeToString( byte[] b )

public byte[] Base64.decodeFromString( String s )


The String the first method produces chunks the output into 76-character lines.  If consumers want very-long single lines instead they can run .replaceAll("\r\n", "") against the output.  (I chose chunking as default behaviour because the breaking a very-long-line into chunks is quite a bit trickier).

Even if this patch is not accepted, I strongly recommend taking in these 5 lines, since they fix a very subtle and rare bug (newly introduced in CODEC-69 I suspect):

{code}
@@ -698,7 +715,11 @@
             len += 4 - mod;
         }
         if (isChunked) {
-            len += (1 + (len / CHUNK_SIZE)) * CHUNK_SEPARATOR.length;
+            boolean lenChunksPerfectly = len % CHUNK_SIZE == 0;
+            len += (len / CHUNK_SIZE) * CHUNK_SEPARATOR.length;
+            if (!lenChunksPerfectly) {
+                len += CHUNK_SEPARATOR.length;
+            }
         }
{code}


      was (Author: juliusdavies):
    codec59.patch attached.  It introduces two new methods:

public String Base64.encodeToString( byte[] b )

public byte[] Base64.decodeFromString( String s )


The String the first method produces chunks the output into 76-character lines.  If consumers want very-long single lines instead they can run .replaceAll("\r\n", "") against the output.  (I chose chunking as default behaviour because the breaking a very-long-line into chunks is quite a bit trickier).

Even if this patch is not accepted, I strongly recommend taking in these 5 lines, since they fix a very subtle and rare bug (newly introduced in CODEC-69 I suspect):

@@ -698,7 +715,11 @@
             len += 4 - mod;
         }
         if (isChunked) {
-            len += (1 + (len / CHUNK_SIZE)) * CHUNK_SEPARATOR.length;
+            boolean lenChunksPerfectly = len % CHUNK_SIZE == 0;
+            len += (len / CHUNK_SIZE) * CHUNK_SEPARATOR.length;
+            if (!lenChunksPerfectly) {
+                len += CHUNK_SEPARATOR.length;
+            }
         }


  
> 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.


[jira] Updated: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julius Davies updated CODEC-59:
-------------------------------

    Attachment: codec59_2009-07-26.patch

Attached "codec59_2009-07-26.patch" introduces following "String" methods to Base64.java:

Non-Static methods:
-------------------------------
1.    public byte[] decode(String pArray)
2.    public String encodeToString(byte[] pArray) {

Static methods:
-------------------------------
3.    public static byte[] decodeBase64(String base64String) 
4.    public static String encodeBase64String(byte[] binaryData) 
5.    public static String encodeBase64URLSafeString(byte[] binaryData)


The "reset()" method doesn't hurt, but isn't really needed unless the CODEC-81 patch is applied, after which it becomes quite important.  The unit-tests exercise the reset().



> 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_2009-07-26.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.


[jira] Updated: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell updated CODEC-59:
-------------------------------

    Issue Type: Improvement  (was: New Feature)

> 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.4
>
>
> 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.


[jira] Commented: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Updated: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julius Davies updated CODEC-59:
-------------------------------

    Attachment:     (was: codec59.patch)

> 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_2009-07-26.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.


[jira] Updated: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julius Davies updated CODEC-59:
-------------------------------

    Attachment: codec59_2009-07-26.patch

You must apply codec81 patches before this one.

> 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
>
>
> 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.


[jira] Resolved: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory resolved CODEC-59.
-------------------------------

       Resolution: Fixed
    Fix Version/s:     (was: 1.x)
                   1.4

Patch applied with one added test code line to keep line code coverage at 100%. Branch coverage up to 92% from 91%.

> 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.4
>
>         Attachments: codec59-2009-07-28.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.


[jira] Updated: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julius Davies updated CODEC-59:
-------------------------------

    Attachment: codec59-2009-07-28.patch

Attached codec59-2009-07-28.patch.

Introduces the String oriented methods previously mentioned in comments here.

Also improves StringUtils handling of null input, as well as Base64.decode() of null.  The reset() calls added to Base64 are pretty important I think in case people try to re-use Base64 objects, e.g.:

{code}
Base64 b64 = new Base64();
b64.encode( someThing );
b64.encode( someOtherThing );
{code}

This will only work with the reset() calls I've added as part of this patch.

> 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-2009-07-28.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.


[jira] Commented: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12735443#action_12735443 ] 

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

I do have a patch ready for this, but it's waiting for CODEC-81 first.  (There are conflicts, so I have to wait.)

> 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
>
>
> 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.


[jira] Updated: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Jochen Wiedmann (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jochen Wiedmann updated CODEC-59:
---------------------------------

    Comment: was deleted

(was: [airline tickets|http://getflightsto.com]
[Parenting|http://childcareforums.com]
)

> 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.4
>
>         Attachments: codec59-2009-07-28.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.


[jira] Commented: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12735706#action_12735706 ] 

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

Attached patch introduces following "String" methods to Base64.java:

Non-Static methods:
-------------------------------
1. public byte[] decode(String pArray)
2. public String encodeToString(byte[] pArray) {

Static methods:
-------------------------------
3. public static byte[] decodeBase64(String base64String)
4. public static String encodeBase64String(byte[] binaryData)
5. public static String encodeBase64URLSafeString(byte[] binaryData)


The patch can only be applied after both of the CODEC-81 patches have been applied.

> 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-but-only-after-codec81.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.


[jira] Updated: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julius Davies updated CODEC-59:
-------------------------------

    Comment: was deleted

(was: You must apply codec81 patches before this one.)

> 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
>
>
> 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.


[jira] Closed: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niall Pemberton closed CODEC-59.
--------------------------------


> 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.4
>
>         Attachments: codec59-2009-07-28.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.


[jira] Commented: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12543153 ] 

Gary Gregory commented on CODEC-59:
-----------------------------------

I've had a need for this in the past as well. This will happen much quicker if you submit a patch for code and unit tests with your request ;-)

> 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: New Feature
>            Reporter: Pepijn Schmitz
>            Priority: Minor
>
> 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.


[jira] Commented: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Joerg Schaible (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12543066 ] 

Joerg Schaible commented on CODEC-59:
-------------------------------------

As explained in CODEC-58 the term character refers 8-bit values in the RFC and 16-bit values in Java. The encoding can never receive a String, since it has no idea about the encoding of the String and the algorithm encodes arbitrary bytes. Same applies to the result of a decoding. The result of an encoding and the input of the decoding could be Strings in ASCII encoding.

> 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: New Feature
>            Reporter: Pepijn Schmitz
>            Priority: Minor
>
> 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.


[jira] Updated: (CODEC-59) Add methods to Base64 which work with String instead of byte[]

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julius Davies updated CODEC-59:
-------------------------------

    Comment: was deleted

(was: Attached "codec59_2009-07-26.patch" introduces following "String" methods to Base64.java:

Non-Static methods:
-------------------------------
1.    public byte[] decode(String pArray)
2.    public String encodeToString(byte[] pArray) {

Static methods:
-------------------------------
3.    public static byte[] decodeBase64(String base64String) 
4.    public static String encodeBase64String(byte[] binaryData) 
5.    public static String encodeBase64URLSafeString(byte[] binaryData)


The "reset()" method doesn't hurt, but isn't really needed unless the CODEC-81 patch is applied, after which it becomes quite important.  The unit-tests exercise the reset().

)

> 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
>
>
> 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.