From: "Phil Steitz" <[EMAIL PROTECTED]>
The example in the bug report looks like a bug to me, which should be fixed. I doubt seriously that anyone is relying on the following kind of bugged behavior:
StringUtils.replaceChars("abc", "abc", "cba") = "aba"
This results from the string being modified and re-searched in a loop over the search characters (so multiple "translations" may be applied, depending on the order of characters in the search string).
As long as the search and replace character strings have the same length, StringUtils.replaceChars() *should* produce the same results as CharSetUtils.translate().
I suggest, therefore
(5) Fix the bug in StringUtils.replaceChars() and improve the javadoc for this method.
+1, replaceChars should be like calling replaceChars(String, char, char) multiple times.
hmm. I think that was what I was referring to as "bugged." The problem is that, as Gary points out above, the old CharSetUtils.translate() really works like a simple translation map, passing the string just one time and performing the indicated character replacements. The behavior now in replaceChars() is as you describe -- so if the replacement map takes c_1 to c_2 and c_2 to c_3 (and c_1 preceeds c_2 in the searchString) the net effect will be c_1 |-> c_3. Is this really how we want it to work?
Phil
Stephen
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
