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