JDK-7190385 : (str) Provide additional trim method(s) that is(are) more intelligent about whitespace
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2012-08-09
  • Updated: 2013-06-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbd_majorUnresolved
Related Reports
Relates :  
Description
See CR 4080617.  In addition, see the blog entry, http://closingbraces.net/2008/11/11/javastringtrim/  

In short, trim() has very limited capabilities and strips off far more (or less) than is desirable.  To quote the blogger, Mike Kaufman -- 

"The String.trim() method talks about ���whitespace���, but defines this in a very precise but rather crude and idiosyncratic way ��� it simply regards anything up to and including U+0020 (the usual space character) as whitespace, and anything above that as non-whitespace.

This results in it trimming the U+0020 space character and all ���control code��� characters below U+0020 (including the U+0009 tab character), but not the control codes or Unicode space characters that are above that."

This RFE is to implement one (or more) additional "trim" methods that are smarter about what is trimmed.  In addition to what is suggested by Mr. Kaufman, we might consider a user-definable trim-set of characters.