[ https://issues.apache.org/jira/browse/CODEC-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12850694#action_12850694 ]
Julius Davies edited comment on CODEC-99 at 3/28/10 5:16 PM: ------------------------------------------------------------- To respond to Gary, here is behaviour of Base64.encodeBase64Chunked(b) through all versions of commons-codec: {code} package playground; import org.apache.commons.codec.binary.Base64; public class Base64ChunkTest { public static void main(String[] args) throws Exception { byte[] b = args[0].getBytes("UTF-8"); b = Base64.encodeBase64Chunked(b); String s = new String(b, "UTF-8"); s = s.replace("\n", "\\n").replace("\r", "\\r"); System.out.println(s); } } {code} {noformat} $ java -cp build/classes:lib/commons-codec-1.1.jar playground.Base64ChunkTest Hello SGVsbG8=\n $ java -cp build/classes:lib/commons-codec-1.2.jar playground.Base64ChunkTest Hello SGVsbG8=\n $ java -cp build/classes:lib/commons-codec-1.3.jar playground.Base64ChunkTest Hello SGVsbG8=\r\n $ java -cp build/classes:lib/commons-codec-1.4.jar playground.Base64ChunkTest Hello SGVsbG8=\r\n {noformat} Just to be clear, you want to change this now after 7 years (the files in the commons-codec-1.1.jar have '2003-04-29' timestamps)? ps. I don't think '=' should be part of the equation, because valid data can encode and not have any '=' characters, for example the string '123': {noformat} $ java -cp build/classes:lib/commons-codec-1.4.jar playground.Base64ChunkTest 123 MTIz\r\n {noformat} was (Author: juliusdavies): To respond to Gary, here is behaviour of Base64.encodeBase64Chunked(b) through all versions of commons-codec: {code} package playground; import org.apache.commons.codec.binary.Base64; public class Base64ChunkTest { public static void main(String[] args) throws Exception { byte[] b = args[0].getBytes("UTF-8"); b = Base64.encodeBase64Chunked(b); String s = new String(b, "UTF-8"); s = s.replace("\n", "\\n").replace("\r", "\\r"); System.out.println(s); } } {code} {noformat} $ java -cp build/classes:lib/commons-codec-1.1.jar playground.Base64ChunkTest Hello SGVsbG8=\n $ java -cp build/classes:lib/commons-codec-1.2.jar playground.Base64ChunkTest Hello SGVsbG8=\n $ java -cp build/classes:lib/commons-codec-1.3.jar playground.Base64ChunkTest Hello SGVsbG8=\r\n $ java -cp build/classes:lib/commons-codec-1.4.jar playground.Base64ChunkTest Hello SGVsbG8=\r\n {noformat} > Base64.encodeBase64String() shouldn't chunk > ------------------------------------------- > > Key: CODEC-99 > URL: https://issues.apache.org/jira/browse/CODEC-99 > Project: Commons Codec > Issue Type: Bug > Affects Versions: 1.4 > Reporter: Julius Davies > Attachments: codec-99-test-fixes.patch, codec-99-tests.patch, > codec-99.patch > > > Base64.encodeBase64String() shouldn't chunk. > Change this: > {code} > public static String encodeBase64String(byte[] binaryData) { > return StringUtils.newStringUtf8(encodeBase64(binaryData, true)); > } > {code} > To this: > {code} > public static String encodeBase64String(byte[] binaryData) { > return StringUtils.newStringUtf8(encodeBase64(binaryData, false)); > } > {code} > This will fix the following tests ggregory added a few minutes ago: > //assertEquals("Zg==", > Base64.encodeBase64String(StringUtils.getBytesUtf8("f"))); > //assertEquals("Zm8=", > Base64.encodeBase64String(StringUtils.getBytesUtf8("fo"))); > //assertEquals("Zm9v", > Base64.encodeBase64String(StringUtils.getBytesUtf8("foo"))); > //assertEquals("Zm9vYg==", > Base64.encodeBase64String(StringUtils.getBytesUtf8("foob"))); > //assertEquals("Zm9vYmE=", > Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba"))); > //assertEquals("Zm9vYmFy", > Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar"))); -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.