You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2003/12/11 20:15:21 UTC
DO NOT REPLY [Bug 25454] New: -
new StringUtils.replaceChars behaves differently from old CharSetUtils.translate
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25454>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25454
new StringUtils.replaceChars behaves differently from old CharSetUtils.translate
Summary: new StringUtils.replaceChars behaves differently from
old CharSetUtils.translate
Product: Commons
Version: 2.0 Final
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: Other
Component: Lang
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: loren@siebert.org
The CharSetUtils.translate(String str, String searchChars, String replaceChars)
method from Lang 1.0.1 is marked deprecated, pointing me at
StringUtils.replaceChars(String str, String searchChars, String replaceChars)
from Lang 2.0. The routines are coded quite differently, and in fact yield
different outputs at times. StringUtils.replaceChars() does not translate some
strings properly.
String original="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
String trans="nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM567891234";
System.out.println(CharSetUtils.translate("d216.102oren", original, trans));
System.out.println(StringUtils.replaceChars("d216.102oren", original, trans));
Running this fragment gets me this:
q651.506bera
d141.401beea
The first one is correct.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org